Property and Enum

S

shapper

Hello,

How do I make a class's property to accept only pre-defined values as
it would be an enum?

Or maybe the enum can be exposed as a property?

Thanks,

Miguel
 
K

Karl Seguin

public class Users
{
private UserStatus _status;
public UserStatus Status { get {return _status;} set {_status =
value;} }

}

public Enum UserStatus
{
Unknown = 0,
Pending = 1,
Banned = 2,
Ok 3,
}

Karl
 

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

Similar Threads

Enum 1
Enum 4
Enum 3
Property default value 1
CheckBox 1
Generic.List 1
Enumeration 2
Create Enum at runtime 1

Top