The if statement in C# is used to execute a block of code if a certain condition is true. The syntax for an if statement is as follows: C# if (condition) { // Code to execute if the condition is true } 123456 if...
Tag - C# if else examples
Write a program to check whether a person is eligible to vote or not in C#
In this tutorial we are writing a C# Program to Check Eligibility for voting. To check that a person is eligible for voting or not, we need to check whether person’s age is greater than or equal to 18. For this we are...
Print Day Name of Week in C#
Write C# Program to print day name of week. I have used Visual Studio 2021 for debugging purpose. But you can use any version of visul studio as per your availability. C# Code: C# static void Main(string[] args) { int week;...
C# program to check whether a given substring is present in the given string
In this tutorial we will learn how to write a c# program to check whether a given substring is present in the given string I have used Visual Studio 2019 Community for debugging purpose. But you can use any version of visual...
Calculate Average of First n Even Natural Numbers in C#
In this example, I’ll show how to find average of First N natural numbers in C#. C# Code: C# static void Main(string[] args) { int n, count = 0, sum=0,average; Console.Write("n : "); n = Convert.ToInt32(Console.ReadLine());...