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

C# Conditional statement

January 25, 2011 1 Comment

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

Comments:1

  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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>