我真的不知道发生了什么。它第一次工作,然后当我尝试第二次失败时我不明白为什么第一个是正确的,但第二个失败
我已经检查拼写,什么也没找到。我很失落没有帮助
我指出了一个//comment
错误行:)
万一我的代码是不言自明的,我想用[1]
选择
获得第二位我的代码是:
static void Main(string[] args)
{
españolizar("55","44");
}
static void españolizar(string str, string str2)
{
string[] list1={"cero","un","dos","tres","cuatro","cinco","seis","siete","ocho","nueve","diez","once","doce","trece","catorce","quince"};
string[] list2={"nivelarindexes","dieci","veinti","trei","cuare","cincue","sese","sete","oche","nove"};
int numero = int.Parse(str);
string strNumero = Convert.ToString(numero);
int primerDigito = int.Parse(Convert.ToString(strNumero[0]));
int segundoDigito = 0;
if (strNumero.Length > 1)
//this is the one that fails
segundoDigito = int.Parse(Convert.ToString(strNumero[1]));
//\-------------------------/
}
Console.WriteLine(strNumero);
Console.ReadLine();
}
你得到的错误信息是什么? – 2012-03-06 15:52:56
这是怎么回事?!?你为什么要将相同的值转换成字符串和从字符串转换得这么多?它伤害了我的大脑! – musefan 2012-03-06 15:53:16
@musefan Parse里面的toStrings是因为我得到一个错误,说'不能从字符转换为字符串'或类似的东西。 (也因为我是C新手新手) – mithril333221 2012-03-06 15:54:25