Answer the question
In order to leave comments, you need to log in
How to properly make an enum with its own class?
If you do it like this:
public enum Classes
{
one = new Class(id = 1),
two = new Class(id = 2),
three = new Class(id = 3),
}
public Classes curClass = two;
int GetId()
{
return curClass.id;// вот так нельзя, потому что не понимает, что enum Classes содержит в себе Class
}
Answer the question
In order to leave comments, you need to log in
You misread the documentation :
It is impossible to do such tricks in Sharpe. You can even overload the cast operator to int inside a Class, but that code still won't compile.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question