I was dong my C# HomeWork when I fell on a little problem.
I can't fix it my self..
Who can help me with my HomeWork?
The Error I'll get with the code under here..
Use of unassigned local variable 'ValidKey'
thx alreadyCode:using System; using System.Collections.Generic; using System.Text; namespace Huiswerk { class Program { static void ShowProfile() { Console.WriteLine("Hello World.."); } static void Say(string Input) { Console.WriteLine(Input); } static void Main(string[] args) { //Declaration of Variables string ValidKey; int RandomKey = 1; string TempStr; //Start Program Say("Type the Following Text: "); switch (RandomKey) { case '1': ValidKey = "qwerty"; break; case '2': ValidKey = "hello"; break; case '3': ValidKey = "enter"; break; } Say(ValidKey); TempStr = Console.ReadLine(); if (TempStr == ValidKey) { Say("Welcome User..\n\t Please Enter.."); //Show Profile ShowProfile(); } else { Say("Invalid!!"); } } } }




Reply With Quote