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