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

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -