I read the answers of the class with the index and property named "Item" , but they do not explain why I can have a class with several indexers, they all create the Item property and get_Item / set_Item (of course, work well, since these are different overloads) but I cannot have an explicit Item property.
Consider the code:
namespace Test { class Program { static void Main(string[] args) { } public int this[string val] { get { return 0; } set { } } public string this[int val]
Four methods have been created for two indexes:
Int32 get_Item(String val) Void set_Item(String val, Int32 value) String get_Item(Int32 val) Void set_Item(Int32 val, String value)
I would expect my property to create
Int32 get_Item() Void set_Item(Int32 value)
These overloads are usually acceptable, but somehow the compiler won't let me create such a property.
Please note that I do not need a way to rename the indexer, etc., this is known - I need an explanation. This answer: https://stackoverflow.com/a/166958/ does not explain why I can have multiple indexers.
source share