Doing some code reading and stumbled upon this snippet that I haven't seen before:
public SomeClass {
public someInterface this[String strParameter] {
get {
return SomeInternalMethod(strParameter);
}
}
}
It looks like it is called as follows:
SomeClass _someClass = new SomeClass();
SomeInterface returnedValue = _someClass["someString"];
I am interested in where this function would be appropriate or what the intent of writing in this style. For example why would this be preferred over simply calling the function?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…