Maybe a confusing title, what I’m after is a class, which only has certain amount of instantiations. Still confused?
What I’m actually after is a list of star ratings(none, half, one, one and a half) etc. So I need a class (or maybe a struct?) which has two fields, value and string representation (for now anyway, leading to other fields; url of image etc). And I need a container for these, a List, ObservColl, IEnumerable, just something to contain them.
But I don’t want the class to be instantiable by anything, except the container object, but still have the class available as a type to set as a field on another class.
Is this possible? Or am I going to have to sacrifice something along the way?
I hope this is what you want:
Make the class public or internal (as you need it), but the constructor private:
Then create a public or internal static method in the class to get your list:
You can now only get a list via this method.
List<MyClass> a = MyClass.GetList();If you want you can implement it with a static property and privat static field, too: