Enumerated property with same name as the enumeration. How?

  • Thread starter Thread starter Chukkalove
  • Start date Start date
C

Chukkalove

Sorry for this dumb (maybe obvious) question.
The property Form.DialogResult is an enumeration of type DialogResult

In my class I have an enumeration called WorkMode.
I want my property also to be called WorkMode but the compiler complains at
the following.
They did it with DialogResult, how can I do this too please.

example:
public class MyClass
{
public enum WorkMode
{
normal,
auto
}

// compiler complains here "The class MyClass already contains a definition
for WorkMode"
public WorkMode WorkMode {
get{return myWorkMode;}
set{myWorkMode = value;}
}

}
 
I worked it out. I took the enumeration out of the class but kept it within
the namespace.Thanks anyway :D

public enum WorkMode
{
normal,
auto
}

public class MyClass
{
public WorkMode WorkMode
{
get{return myWorkMode;}
set{myWorkMode = value;}
}
}
 
Back
Top