Inline if else condition in c#
Its mostly use assign only one variable or object
Example: you have a variable and you want to check null value
Example: you have a variable and you want to check null value
int a = 100; string result = string.Empty; if (a < 20) { result = "a variable less than 20"; } else { result = "a variable not less than 20"; }you can use instead of old condition because its a major benefit to reduce line of code
int a = 100; string result = a < 20 ? "a variable less than 20" : "a variable not less than 20";
Comments
Post a Comment