csharp Conditional Operator

expression ? true : false;

int a = 1;
int b = 2;
string result;

result = (a > b ? "a is greater than b" : "b is greater than a");
//result = "b is greater than a"
Example usage of the Conditional Operator: http://msdn.microsoft.com/en-us/library/ty67wk28(vs.71).aspx

Updated: Thursday 4th November 2010, 18:55pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.