我真的不知道發生了什麼。它第一次工作,然後當我嘗試第二次失敗時我不明白爲什麼第一個是正確的,但第二個失敗
我已經檢查拼寫,什麼也沒找到。我很失落沒有幫助
我指出了一個//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