how can I change this condition to that I want

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];

Using nested ternary operators sacrifices readability for brevity. I recommend using the humble switch statement instead:

string foo(int status)
{
    switch (status)
    {
        case 0:
            return "Present";
        case 1:
            return "Absent";
        case 3:
            return "Unacceptable absent";
        default:
            throw new ArgumentOutOfRangeException(nameof(status), $"What kind of person passes {status}?");
    }
}

you could add a failsafe status as "NA" and do it as follows :

status == 0 ? "Absent" : status == 1? "Present" : status == 3? "Unacceptable Absent" : "NA";

Tags:

C#

Asp.Net