C# if statement | c# if | if c# - c# - c# tutorial - c# net




C# If Statement

Learn c# - c# tutorial - C# If Statement - c# examples - c# programs

What is if statement in C# ?

  • In C#, an if statement consists of a Boolean expression followed by one or more statements.
 c sharp if statement string

Syntax:

if (condition) 
{
   condition statement is true;
}
click below button to copy the code. By - c# tutorial - team

if statement in c#

if statement in c#

C# Sample Code - C# Examples:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace wikitechy_if_condition
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 5;

	        if (n <= 5)

	        {
              Console.WriteLine("wikitechy says this condition is true");
            }

           Console.ReadLine();

        }
    }
}
click below button to copy the code. By - c# tutorial - team

Code Explanation:

 c sharp if operator
  1. Here n = 5 is an integer variable value as 5.
  2. Here, if (n <= 5) expression specifies the n =5 is less than, or equal to 5 i.e., (5 <= 5), which executes the statement "wikitechy says this condition is true".

Sample C# examples - Output :

 nested if else in c sharp
  1. Here the statement executes the if condition by printing the statement "Wikitechy says this condition is true".


Related Searches to C# if statement | c# if | if c#

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×