properties - Strange C# property definition(indexer) -


how different normal property in c#?

    public new point3d this[int index]     {         { return base[index]; }         set         {             base[index] = value;             collectionmodified();         } 

this indexer; instead of being used obj.foo, used obj[index], i.e.:

var oldval = obj[1]; obj[1] = newval; 

it "different" because:

  • it has no explicit name
  • it accepts parameter (or parameters)

note indexer parameters not have integers; can sorts:

dictionary<string, decimal> lookup = ... string employeekey = "000006"; decimal salary = lookup[employeekey]; 

Popular posts from this blog

Php - Delimiter must not be alphanumeric or backslash -

c# - How to change the "Applies To" field under folder auditing options programatically (.NET) -

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -