Deutsch
Germany.ruФорумы → Архив Досок→ Программирование

Вопросы по C#

26.10.13 22:20
Re: Вопросы по C#
 
Mahone постоялец
в ответ AlexNek 26.10.13 21:24
Спасибо!! Теперь работает!)
Переделал кусок кода так:
            do
{
int playerMatches;
string inputLine;
bool Matches = true;
do
{
// Asks to enter the amount of matches
Console.Write("Wie viele Hölzer nimmst Du: ");
inputLine = Console.ReadLine();
// Checks if amount of matches is from 1 to 4. Only digits are allowed.
// If no, asks to re-enter the amount.

if (!int.TryParse(inputLine, out playerMatches))
{
Matches = false;
Console.WriteLine("Falsche Zahl. Wiederhole die Eingabe.");
}
else if (playerMatches > 4 || playerMatches < 1)
{
Matches = false;
Console.WriteLine("Falsche Zahl. Wiederhole die Eingabe.");
}
else
{
break;
}
}
while(!Matches);
playerMatches = Convert.ToInt32(inputLine);
// Calculates amount of remaining matches and print them on the screen
sumMatches = sumMatches - playerMatches;


 

Перейти на