csharp If Statement Syntax

if ((1).ToString() == "1")
{
	Console.WriteLine("1 is equal to 1");
}
else
{
	Console.WriteLine("You won't ever get here");
}

if ((1).ToString() == "1")
	Console.WriteLine("1 is equal to 1");
else
{
	Console.WriteLine("You won't ever get here");
}

if ((1).ToString() == "1")
{ Console.WriteLine("1 is equal to 1"); }
else
{ Console.WriteLine("You won't ever get here"); }

if ((1).ToString() == "1") { Console.WriteLine("1 is equal to 1"); }
else { Console.WriteLine("You won't ever get here"); }

if ((1).ToString() == "1")
	Console.WriteLine("1 is equal to 1");
else
	Console.WriteLine("You won't ever get here");

if ((1).ToString() == "1") Console.WriteLine("1 is equal to 1");
else Console.WriteLine("You won't ever get here");
Examples of differing Syntax for an if statement - all of which are valid.

Updated: Friday 8th October 2010, 08:22pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.