junior1998
New member
- Joined
- Oct 16, 2018
- Messages
- 2
- Programming Experience
- Beginner
hello everybody
my name ist steven and i'm beginner in c#. Excuse me but my english ist not very good.I have received a homework at the university and i'm having some problems with the code. I have code a little program with a lot of do-while expression and if expression. But in these expression some variables are receiving some values. The problem is that i can't use these variables after the do-while expression. I receive the message with underline variables "use of local unassigned variables". I notice that i'm in german so there is some german in my code.
my name ist steven and i'm beginner in c#. Excuse me but my english ist not very good.I have received a homework at the university and i'm having some problems with the code. I have code a little program with a lot of do-while expression and if expression. But in these expression some variables are receiving some values. The problem is that i can't use these variables after the do-while expression. I receive the message with underline variables "use of local unassigned variables". I notice that i'm in german so there is some german in my code.
string eingabeLänge1, eingabeLänge2, eingabeLänge3;
double länge1, länge2, länge3, ergebnis;
double essai1;
Console.WriteLine("Also das war schon leicht für mich können Sie mir eine schwierigere Aufgabe geben? Wie die Berechnung der Flächeninhalt eines Dreieicks");
do
{
Console.WriteLine("Nehmen wir an es ist ein beliebiges Dreieck\n Und geben Sie die erste Länge");// asking for the value of my variable
eingabeLänge1 = Console.ReadLine();
if (double.TryParse(eingabeLänge1, out länge1))// verify if what is entered can be transform in double
{
do
{
Console.WriteLine("Ok gut und jetzt die zweite Länge!");//asking for the value of my variable
eingabeLänge2 = Console.ReadLine();
if (double.TryParse(eingabeLänge2, out länge2))// verify if what is entered can be transform in double
{
do
{
Console.WriteLine("Fast geschafft fehlt nur die dritte Länge!");// asking for the value of my variable
eingabeLänge3 = Console.ReadLine();
if (double.TryParse(eingabeLänge3, out länge3)) // verify if what is entered can be transform in double
{
Console.WriteLine("Ok perfekt jetzt arbeite ich wirklich!");
}
else
{
Console.WriteLine("Oh nöö est muss ein Zahl sein!");
}
} while (!double.TryParse(eingabeLänge3, out länge3));// repeat the action until the user enter a correct number
}
else
{
Console.WriteLine("Oh nöö est muss ein Zahl sein!");
}
} while (!double.TryParse(eingabeLänge2, out länge2));//repeat the action until the user enter a correct number
}
else
Console.WriteLine("Oh nöö est muss ein Zahl sein!");
} while (!double.TryParse(eingabeLänge1, out länge1));// repeat the action until the user enter a correct number
Console.WriteLine("youpi");
ergebnis = (länge1 + länge2 + länge3) / 2; // i received a message on the underline words " use of unassigned local variable
Last edited by a moderator: