Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Need help with debugging error CS0165 on C#

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;




When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
    Bookmark Topic Watch Topic
  • New Topic