The only issues I can see (I think!) are that you need to store the value inside the Status
object otherwise the value is just returned and not utilised. Secondly make sure you use .ToUpper()
on the l
variable, just in case the data from the database is in lowercase. Unless you want any lowercase values to fall through to the default
of the switch
statement.
Now if you want to access the value, just use SampleData.Status.Value
.
public class Status
{
public string Value { get; set; }
//public Status() { }
public Status(string l)
{
switch (l.ToUpper())
{
case "A":
Value = "Yes";
break;
case "B":
Value = "No";
break;
case "C":
Value = "Okay";
break;
case "D":
Value = "Maybe";
break;
case "E":
Value = "Need More Info";
break;
default:
Value = "Unknown";
break;
}
}
}