First question: output these three names
string[] name = new string[] {"Messi", "Kaka", "Jong"};
for (int i = 0; i < name. Length-1; i++)
{
Console.Write (name[i]+ "\ t");
}
Console.Write (Name[name. Length-1]);
Console.ReadLine ();
Second question: Each element of an array of integers is processed, if the element is positive, the element is added one, if the element is negative, the element is reduced by one
Int[] Shu=new int[]{1,3,5,-2,-3};
for (int i = 0; i < Shu. Length; i++)
{
if (shu[i]>0)
{
shu[i]++;
}
else if (shu[i]<0)
{
shu[i]--;
}
}
for (int i = 0; i < Shu. Length; i++)
{
Console.WriteLine (Shu [i]);
}//parentheses define the variable, which can only be used within parentheses
Note that the scope of I in the For loop, except for this scope, I cannot use the
Console.ReadLine (); */
Third question: Invert elements of a set of string types
String[] Shu = new string[] {"Hello", "a", "true", "ball", "why", "127"};
for (int i = 0; i < Shu. LENGTH/2; i++)//In the computer, 7/2=3, because it is an integer type
{
String temp = Shu[i];
Shu[i] = Shu[shu. Length-1-i];
Shu[shu. Length-1-I] = temp;
}
for (int i = 0; i < Shu. Length; i++)
{
Console.WriteLine (Shu[i]);
}
Console.ReadLine ();
A few examples of the basis of the array, very practical, many knowledge points. Output data using an array.