I have an enum class called Gender, and I have values in this like:
public enum GENDER
{
MALE = 1,
FEMALE = 2,
OTHERS = 3,
}
And in my business object I just created a property for this, like:
public GENDER Gender
{
get
{
return gender;
}
set
{
gender = value;
}
}
In my database it’s in type integer. For this I tried to assign the Gender value in the add function by its name Gender. But it’s showing an error. Is it possible to cast the enum to integer so that it’ll get the value automatically.
How can I fix this?
If (int)Gender is not enough to fix your cast issue, try to add int.Parse(var, int) in your code. It might be helpful…