View Single Post
Old 08-10-2007, 11:42 PM   #13 (permalink)
Sep102
Forum Expert
 
Join Date: Aug 2004
Location: Redmond, WA
Age: 21
Posts: 1,288
Send a message via AIM to Sep102 Send a message via MSN to Sep102
Default

Sorry, guess I should have explained a few terms better.

Quote:
Originally Posted by Kaon
A property (get/set) never takes arguments, unless it is a array type and use [i] to access index ... no? How do you declare a indexer ? What it is? :/ (just to know, disgression of the actual problem ^^)
An indexer is a property that "is a array type and use [i] to access index", it's one of the many names for properties that are accessed as "[i]" (which, as I stated, is a property that takes arguments, likewise you could have a property that takes two arguments and access it as "[i1, i2]"). And, as you probably know already (knowing what an indexer is now) you declare an indexer like "public Int32 this[Int32 index] ..."

Quote:
Originally Posted by Kaon
(exactly what I want ^^)
I searched such a property with name "this" ( public T this[int index] { get; set; }) or others in the metadata definition of List<> ... And I checked again the metadata, and can't find the Item Property ... where is it defined ? I checked the herited classes too :/

Without testing, the first thing coming up to my mind is that it won't find any property with the name "Item" :/
Can you explain a litlle bit more ?
If you used Visual Studio's Object Browser to look for it, then you're correct, you won't find an Item property in List (however you will if you use Reflector to browse classes, which, by the way, is quite an invaluable tool). As I said, it does have an Item property, as that is the default name that it gives to a class's array properties. So, while you won't be able to find it in the Object Browser, it does exist, and is the way you access the array property when using Type.GetProperty() (so, to access List's this[Int32] property, you would use prop2 = lst.GetType().GetProperty("Item"), then you could access it the way that you were trying to).

Last edited by Sep102; 08-10-2007 at 11:47 PM.
Sep102 is offline   Reply With Quote