我是 c# 的新手,预计会出现错误;这是什么意思
i'm new in c# and getting error expected; what does it means
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("hi..! :)");
Console.WriteLine("Welcome to 1st program of console by ali which is marksheet...:P ;)");
Console.WriteLine("Enter the marks of subjects..");
Int32[] array = new int[5];
Console.WriteLine("Enter the marks of Maths..!");
array[0] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the marks of Arabic..!");
array[1] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the marks of English..!");
array[2] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the marks of Science..!");
array[3] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the marks of Physics..!");
array[4] = Convert.ToInt32(Console.ReadLine());
for(Int32 i=0 i < array.Length i++)
{
Console.WriteLine(i + " is the obtained marks from 500..");
}
Console.ReadKey();
}
}
}
将 for 循环更改为:
for(Int32 i=0 i < array.Length i++)
{
Console.WriteLine(i + " is the obtained marks from 500..");
}
收件人:
for(Int32 i=0; i < array.Length; i++)
{
Console.WriteLine(array[i].ToString() + " is the obtained marks from 500..");
}
此外,在任何语言中使用 "array" 作为变量名通常都不是好的做法。您可能希望将数组变量名称更改为更类似于 myArray 或 my_array.
的名称
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("hi..! :)");
Console.WriteLine("Welcome to 1st program of console by ali which is marksheet...:P ;)");
Console.WriteLine("Enter the marks of subjects..");
Int32[] array = new int[5];
Console.WriteLine("Enter the marks of Maths..!");
array[0] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the marks of Arabic..!");
array[1] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the marks of English..!");
array[2] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the marks of Science..!");
array[3] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the marks of Physics..!");
array[4] = Convert.ToInt32(Console.ReadLine());
for(Int32 i=0 i < array.Length i++)
{
Console.WriteLine(i + " is the obtained marks from 500..");
}
Console.ReadKey();
}
}
}
将 for 循环更改为:
for(Int32 i=0 i < array.Length i++)
{
Console.WriteLine(i + " is the obtained marks from 500..");
}
收件人:
for(Int32 i=0; i < array.Length; i++)
{
Console.WriteLine(array[i].ToString() + " is the obtained marks from 500..");
}
此外,在任何语言中使用 "array" 作为变量名通常都不是好的做法。您可能希望将数组变量名称更改为更类似于 myArray 或 my_array.
的名称