public static void Main()
{
char[] a=new char[100];
char[] b=new char[100];
int i=0,j=0;
char c=(char)Console.Read();
Console.WriteLine("please input a $(0-99):\n");
while(c!='\n'&i<99&j<99)
{
if(c>=48&c<=57)
{
a[i++]=c; }
else if(c>=65&c<=90)
{
b[j++]=c;
}
else
{
//
}
}
a[i]='\0';
b[j]='\0';
Console.WriteLine("a[i]={0}",a);
Console.WriteLine("b[j]={1}",b); }
错误为:未处理的system.format exception类型的异常出现在mscorlib.dll中,其他信息:索引从0开始必须大于或者等于0且小于参数列表的大小。谢
{
char[] a=new char[100];
char[] b=new char[100];
int i=0,j=0;
char c=(char)Console.Read();
Console.WriteLine("please input a $(0-99):\n");
while(c!='\n'&i<99&j<99)
{
if(c>=48&c<=57)
{
a[i++]=c; }
else if(c>=65&c<=90)
{
b[j++]=c;
}
else
{
//
}
}
a[i]='\0';
b[j]='\0';
Console.WriteLine("a[i]={0}",a);
Console.WriteLine("b[j]={1}",b); }
错误为:未处理的system.format exception类型的异常出现在mscorlib.dll中,其他信息:索引从0开始必须大于或者等于0且小于参数列表的大小。谢
1.VS.net 2003
2.microsoft clr debugger 2003
3.visual studio.net 2003
thank you
Console.WriteLine("please input a $(0-99):\n"); //顺序应放在上面吧?
char c=Convert.ToChar(Console.ReadLine());
也是这种错误。
错误为:未处理的system.format exception类型的异常出现在mscorlib.dll中,其他信息:索引从0开始必须大于或者等于0且小于参数列表的大小。谢
使用Read方法传回的是一个字符的Ascii码
char c=(char) Console.Read(); //只读一个
string strRead=Console.ReadLine();//读取当前行