I’m trying to make a class where you can access a collection in it and get an item using a string index, (I hope this makes sense), basically I would like to know either what this is called or how to do it?
here is an example of what I mean;
string blah = SomeClass.Items["Item1"].ToString();
Hopefully someone can make some sense of this.
Thank You.
I think you are looking for an indexer.
In your case you want to index using a string. Something like this:
It may be that you would be better off removing the
Itemslayer from your syntax. That would result in your code reading like this: