I'm all new to Enum types and seems like I can't figure something out in my project. I was asked to use Enum for creating a combobox with pre-defined values. What I did was:
namespace Models
{
public class LastStatus
{
public LastStatus()
{
}
public int ID { get; set; }
public enum description { inProgress, done, accepted }
public description desc;
public int constant { get; set; }
}
}
And this is my method for converting the DB model to my own model before I use them: (e.g add them to a List and then iterate over it to add to the combobox's listitems in aspx.cs side)
private Models.LastStatus ConvertStatusDbToObject(DBModel.myDB.LastStatu status)
{
Models.LastStatus statusObject = new Models.LastStatus();
statusObject.ID = status.ID;
//statusObject.description = status.description;
(LastStatus.description)statusObject.desc = (LastStatus.description)status.@const;
statusObject.constant = status.@const;
return statusObject;
}
I get the error on this line:
(LastStatus.description)statusObject.desc = (LastStatus.description)status.@const;
when trying to cast the integer value of the DB Model to my enum type. Isn't desc a property?
Error 23 The left-hand side of an assignment must be a variable, property or indexer
object o = new object(); o = (int)1;is OK but this is notobject o = new object(); (int)o = (int)1;