Enumerated property with same name as the enumeration. How?

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;}
}

}
 
C

Chukkalove

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;}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top