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();

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 - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions