I have a condition with two value. if the condition equal to 0
it return Absent
and if equal to 1
it returns present
.
now I want to add the third value into my condition. if the condition equal to 3
it returns Unacceptable absent
.
this is my conditions with two value:
(status >= 1 ? "Present" : "Absent")
how can I change the condition?
Use a lookup dictionary.
//Initialized once in your program
var lookup = new Dictionary<int,string>
{
{ 0, "Absent"},
{ 1, "Present"},
{ 3, "Unacceptably Absent" }
};
//Call this whenever you need to convert a status code to a string
var description = lookup[status];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With