Showing posts with label lines. Show all posts
Showing posts with label lines. Show all posts

Thursday, March 29, 2012

Please explain me following lines

Hi All,

Please explain me following two lines:

if (combined.Length != 0)

prefix += appendAnd ? " and " : " ";

In above line what is the use of '?' and ':'

Thanks and regards,

Swapnil.

That is aTernary Expression.

If means,

If the var appendAnd evaluates to True

then perform the operation (+=) with the data directly after the question mark

else

perform the oprtation with the data after the colon :