Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Declare a plastic array with the size of 10, assign a value to it, and calculate how many odd c# s there are. I hope it's simple. Thank you.
Declare a plastic array with the size of 10, assign a value to it, and calculate how many odd c# s there are. I hope it's simple. Thank you.
Please refer to the following code:

//Define an array

int[]list = new int[ 10];

//Loop and assign a value.

for(int I = 0; I< 10; i++)

list[I]= I;

//Defines the total number of variable records.

int count = 0;

//enumeration. If it is odd, the count will be increased by 1.

Foreach (int i in the list)

if(I % 2 = = 1)count++;

//Displays the total number of odd numbers.

MessageBox。 Display (count. ToString());