• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Need help with debugging error CS0165 on C#

 
Greenhorn
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
 
Greenhorn
Posts: 9
C++ Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are talking about the line:

You never initialized or assigned the variable, so when you give the Console the var, it will write null. Try this when you call the variable:

or


Also, just a side note, if you are trying to make a list (I infer from the "Names" part of your variable names), try looking into using an array, a list, or even a dictionary.
 
Bartender
Posts: 1737
63
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is Java C# something I am confused about or a Pure Typo??
 
Saloon Keeper
Posts: 15727
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, Java C# is not a thing.

This is just plain old C#, so I'm removing it from the Java forums.
 
Stephan van Hulst
Saloon Keeper
Posts: 15727
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nav, you really should not declare all your variables at the start of the method. It's not the 1970's. You should declare a variable when you first start using it.
 
Let nothing stop you! Not even this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic