This is probably a very simple question but I am new to C# and can't figure out how to get the value of my enum?
public enum Status
{
OK,
Bad,
}
I want to display it as follows (hard coded at the moment):
public Task<ResultData[]> GetResults()
{
var dummyData = new ResultData();
dummyData.Title = "title";
dummyData.Status = Status.OK;
dummyData.Value = 5;
var results = new ResultData[] { dummyData };
return Task.FromResult(results);
}
However this shows the status as 0
not OK
. I want it to show OK
in the array when I use this GetResults()
method. I have tried Status.OK.ToString()
as many other posts have suggested but I get the error that it cannot convert the string
to the type Status
. I have looked at other articles but cannot seem to figure out a simple way of doing this - can anyone assist?
Thanks