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];