T
T
TheTalion2017-06-04 03:44:07
C++ / C#
TheTalion, 2017-06-04 03:44:07

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),
}

And then create a variable like this:
public Classes curClass = two;

int GetId()
{
return curClass.id;// вот так нельзя, потому что не понимает, что enum Classes содержит в себе Class
}

How to make the variable understand that the enum contains classes? And how, in your opinion, is the correct one suitable? Vsm. You can also create a sheet or an array and put these variables there.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2017-06-04
@TheTalion

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 question

Ask a Question

731 491 924 answers to any question