I have a simple class:
public class MyClass
{
public string MyClassName { get; private set; }
public string MyClassValue { get; private set; }
}
And I want to hold an array of MyClass objects like this:
MyClass[] myClasses = new MyClass[5];
Is it possible, without creating a “collection” object, to be able to access one of those objects in the array of objects by the string indexer (is that the right terminology)?
For example, if myClasses[2] has the value “andegre” in the MyClassName property, how/can I access it like this:
MyClass andegre = myClasses["andegre"];
Instead of doing something like:
MyClass andegre = myClasses[GetIndexOfOfMyClassName("andegre")];
TIA
Welcome to the world of LINQ!