Property to accept only an enum type

  • Thread starter Thread starter Guest
  • Start date Start date
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; }
}
}}
 
property should have been:

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

not int type
 
Back
Top