Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

check if number is even or odd c#

int i = 5;
if (i % 2 == 0)
{
	// even
}
else
{
	// odd
}
Comment

how to check if a number is even in c#

int num = 100;

if (num % 2 == 0){
  Console.WriteLine($"{num} is an even number");
}
else if (num % 2 != 0){
  Console.WriteLine($"{num} isn't an even number");
}

// wait before closing
Console.ReadKey();
Comment

c# is odd number

// using modulo operator %
if(num%2 == 0){
  Console.WriteLine("Number is even")
}else{
  Console.WriteLine("Number is odd")
}
Comment

how to see if a number is even c#

bool IsEven = ( number %2) == 0
bool IsOdd = ( number %2) == 1
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# stop 
Csharp :: set mouse over colors for button wpf 
Csharp :: C# reflection invoke static generic method 
Csharp :: executable path with app name c# 
Csharp :: on collision 2d unity 
Csharp :: website link in unity 
Csharp :: unity rigidbody freeze all 
Csharp :: check if ienumerable is empty c# 
Csharp :: c# fontweight in code 
Csharp :: when do i need to end a sentence with ; in c# 
Csharp :: serializefield for animator 
Csharp :: c# find index element array 
Csharp :: unity detect if version is a build or in editor 
Csharp :: unity mesh showing Instance 
Csharp :: after each vue router 
Csharp :: unity how to ommit letters from a string 
Csharp :: c# declare inline string array 
Csharp :: orderbyascending c# 
Csharp :: visual studio windows form exit button 
Csharp :: how to know what object player touches unity 2D 
Csharp :: how to add b to a string in java 
Csharp :: unity put children in list 
Csharp :: c# display a variable to a text gameobject 
Csharp :: c# 2-dimensional array sort 
Csharp :: list of all c# keywords 
Csharp :: Specified key was too long; max key length is 1000 bytes (SQL: alter table `permissions` add unique `permissions name guard_name_unique`(`name`, `guard_name`)) 
Csharp :: c# decimal to hex 
Csharp :: c# string to hex 
Csharp :: c# start file 
Csharp :: select a object from list based on a value csharp 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =