single line if statement c#

single line if statement c# .net

We can use the single line if statement c# .net. The below given example is might help you.

This is the Default query as given below

(if) ? then : else


Check the month using single line if in c# .net as given below


result = (month == 1) ? "Jan" : DateTime.Now();
ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Buy Books Online at Best Prices

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.