Advertisement



< Prev
Next >



C# else if Statement




In C#, an else-if statement consists of three parts -







Working of else-if


First the condition in the parenthesis of if is evaluated for a boolean value - true or false.




Advertisement




else if statement example


//C# else if statement example

using System;

class ElseIfEx
{
public static void Main()	
{
	int a = 99, b = 100, c = 90;
	if(a>b)
		Console.WriteLine("{0} is greater than {1}", a, b);
	else if(a<c)
		Console.WriteLine("{0} is less than {1}", a, c);
	else
		Console.WriteLine("{0} is greater than {1} and less than {2}", a, c, b);
}
}


Output


99 is greater than 90 and less than 100




Please share this article -





< Prev
Next >
< C# If Else Statement
C# Nested If Statement >



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement