+ 3

if else in C#

how to check the array is empty in C# using if else statement. That is, if array is empty, I want to print that "The array is empty". Please help me.

25th Oct 2017, 8:30 AM
Ramees Rahman
Ramees Rahman - avatar
2 Réponses
+ 5
Assuming array is called arr: if(arr.Length == 0) { Console.WriteLine("The array is empty"); }
25th Oct 2017, 8:54 AM
Bagshot
Bagshot - avatar
0
int x= 1; if(x==1){ Console.WriteLine("Yes"); }else{ Console.WriteLine("No"); }
25th Oct 2017, 8:53 AM
Abderrahim Oukhrib
Abderrahim Oukhrib - avatar