0

I stumble upon a piece of C# code that I don't understand, like this:

public class ClassA {
public ClassB this[EnumA key] {
    get {
            ClassB b;
            dictionaryB.TryGetValue(key, out b);
            return b;
    }

}

... }

I don't understand the syntax of "ClassB this[EnumA key] {...", what is it?

Mingheng Wang
  • 125
  • 2
  • 9

1 Answers1

1

This is the indexing operator. It's used by collections most usually to give a callee a direct reference to an object in its storage.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
tigerswithguitars
  • 2,497
  • 1
  • 31
  • 53