mardi 5 juillet 2016

C# Smart If Statment

is there a way to rewrite these if a statements in a shorter and smarter way? Please note that checking var for null is important because I want to avoid the exceptions.

C#

if(var==null)
 {return 0;}

if(var.ToString()=="A")
{return 1;}
else 
{return 0;}

Aucun commentaire:

Enregistrer un commentaire