Win a copy of Java Challengers this week in the Java in General forum!

Nav Faz

+ Follow
since Apr 01, 2021
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nav Faz

Hi there, I am new to this forum and was referred to here by a kind redditor so I decided to come here to ask my question, basically, I was trying to make a to-do list console app using Java C#, however, while trying to use a string variable in a switch statement, I ran into error CS0165 which states that I am using an unassigned local variable. What does this error mean and how do I fix it?
PS: Here's the code from the program I was trying to write, I ran into an error at around the last line, would really appreciate any help or advice asap
class Program
       static void Main(string[] args)

           //booleans to be used

           bool newtask;
           bool completetask;
           bool motivateme;
           bool addquote;
           bool incompletedtasklist;
           bool incompletedtasknum;
           bool completedtasklist;
           bool completedtasknum;
           bool help;
           bool oops;

           //all variables to be used

           Int32 IncompletedTaskNum;
           Int32 CompletedTaskNum;
           string IncompletedTaskNames;
           string CompletedTaskNames;
           string MotivationalQuotes;
           string OopsQuotes;
           string CommandName;
           string NewTask = "newtask";


           //procedures for program

           Console.WriteLine("Hello User, what would you like to do today?");

           CommandName = Console.ReadLine();

           //if (CommandName == "newtask")
               //newtask = true;

               case "newtask":
                   newtask = true;
                   Console.WriteLine("Please enter the name of this task.");
                   IncompletedTaskNames = Console.ReadLine();
               case "completetask":
                   completetask = true;
                   Console.WriteLine("Please enter the name of the task that you have completed.");
                   CompletedTaskNames = Console.ReadLine();
               case "motivateme":
                   motivateme = true;
                   Console.WriteLine("You can do it!");
               case "addquote":
                   addquote = true;
                   Console.WriteLine("Please enter the quote that you would like to add.");
                   MotivationalQuotes = Console.ReadLine();
               case "incompletedtasklist":
                   incompletedtasklist = true;




1 month ago