Home > .Net Basic | C# > C# Conditional statement

C# Conditional statement

A neat syntax in C#

isTrue ? thenDoThis : ElseDoThis

bool isBodyHTML=onFileReceived.Attributes["isBodyHTML"].Equals("true")?true:false

Another example of use

StringBuilder sb = new StringBuilder();
sb.AppendLine("Inner Exception " + ex.InnerException==null?"null":ex.InnerException.Message);

Tags: csharp .net basic C# conditional statement


  1. alpha
    January 14, 2012 at 3:25 am

    hello sir
    i am alpha
    i want simple c book and
    i want strong seo backlink code
    thank u sir

Leave a Reply

Your email address will not be published. Required fields are marked *