Вот мой код сначала
public void StringToInt(int[] arrPart, int temp , string[] arrPartStr)
{
for (int c = 0; c < arrPart.Length; c++)
{
temp = 0;
if (arrPartStr[c][0] == 'P') temp = PLAYER * 100;
else if (arrPartStr[c][0] == 'B') temp = BANKER * 100;
else temp = TIE * 100;
if (arrPartStr[c][1] == 'P') temp += PLAYERBANKER;
if (arrPartStr[c][2] == 'P') temp += BANKERPLAYER;
arrPart[c] = temp;
}
}
public static string SplitString(string history)
{
string[] text = history.Split(',');
return history;
}
Теперь здесь я применяю все те методы, которые я создал
public void firstMethod(string history)
{
string[] arrPartStr = new string[] { SplitString(history) };
int[] arrPart = new int[arrPartStr.Length];
int temp = 0;
StringToInt(arrPart, temp, arrPartStr);
}
Теперь то, что происходит здесь, это то, что код внутри firstMethod()
не работает должным образом, как я так сказал.Потому что это не дает ожидаемый результат, который я хочу.Но следующий код
public void firstMethod(string history)
{
string[] arrPartStr = history.Split(',');
int[] arrPart = new int[arrPartStr.Length];
for (int c = 0; c < arrPart.Length; c++)
{
int temp = 0;
if (arrPartStr[c][0] == 'P') temp = PLAYER * 100;
else if (arrPartStr[c][0] == 'B') temp = BANKER * 100;
else temp = TIE * 100;
if (arrPartStr[c][1] == 'P') temp += PLAYERBANKER;
if (arrPartStr[c][2] == 'P') temp += BANKERPLAYER;
arrPart[c] = temp;
}
}
отлично работает, когда я просто помещаю код прямо в firstMethod()
.Может ли кто-нибудь объяснить мне, почему.