Property to accept only an enum type

G

Guest

Hi all,
How do I make a property accept only a value from an enum type? Let's say
for example:
using System;
namespace Test {
enum ItemTypes {Raw,Full,Kit}
class Item {
Type itemType = typeof(ItemTypes);
public Item() {}
public int ItemType // I want the allowed value to be of ItemTypes type.
How?
{
get { return itemType; }
set { itemType = value; }
}
}}
 
J

joeycalisay

property should have been:

public ItemTypes ItemType
{
get{ return iTemType; }
set{ iTemType = value; }
}

not int type
 

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

How to get/set an enum type? 5
Enums & Constructors? 4
Enum Extentions 7
How to make enum class member visible? 4
Error LNK2091 1
Enum 1
How to cast using a Type object? 10
Casting of a Object* to an Enum value?? 2

Top