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 - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book