读书人

请教各位大侠…

发布时间: 2012-01-30 21:15:58 作者: rapoo

请问各位大侠……
以下是把程序无法通过编译,请问各位大侠如何解决??


using System;


class test
{
public static void Main(String[] args)
{
if (args.Length < 1)
{
Console.WriteLine( "No arguments ");
}
else
{
String text;
for (int i = 0; i < args.Length; ++i)
{
text = args[i];
for (int j = 0; j < text.Length; ++j)
{
if (text[j] > = 'a ' && text[j] <= 'z ')
text[j] =(char)text[j]- 32;
}

Console.WriteLine(text);

}
}
}
}

[解决办法]
using System;

class test
{
public static void Main(String[] args)
{
if (args.Length < 1)
{
Console.WriteLine( "No arguments ");
}
else
{
for (int i = 0; i < args.Length; ++i)
{
string text = args[i];
char[] ch = text.ToCharArray();
for (int j = 0; j < ch.Length; ++j)
{
if (ch[j] > = 'a ' && ch[j] <= 'z ')
ch[j] = (char)((int)ch[j] - 32);
}

Console.WriteLine(ch);
}
}
}
}

读书人网 >C#

热点推荐