C# Ternary Operator – How to Use Conditional Operator

c++conditional-operator

int number = 5;
  • when the number is equal to 5, write true
  • when the number is not equal to 5, write false

How do I write a statement for this in ASP.NET using C#?

Best Answer

int five = 5;
string answer = five == 5 ? "true" : "false";

I see that you want to use this to write the values out in ASP.NET, the answer string will hold your desired value, use that as you please.

Related Question