• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How do I access a variable from a switch statement?

Resolved: How do I access a variable from a switch statement?

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have just started learning C# with one of brackey’s tutorials, and I have tried to make a simple quiz. I have tried everything I could have thought to do (basically deleting instances of the variables I was having trouble with), and I can’t find anything online that I can understand or implement into my current scenario.
My issue is I can’t seem to reference these correct01 and 02 variables so that I can display the correct amount of points. I’m not sure if this is because they are defined in the switch statement but I can’t seem to use them anywhere else. VS Code is also complaining that they are not used in the switch statement themselves.
Overall, I need a way to reference the correct01 and 02 variables from inside the switch statements.

Answer:

Because you had decalred two variable with the same name.
Remove the bool that is in the switch statement

If you have better answer, please add a comment about this, thank you!

c#
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to scroll bottom of div at launch?

02/04/2023

Resolved: how to get and read an xml file in a zip file using xml.etree

02/04/2023

Resolved: The ‘Access-Control-Allow-Origin’ header contains multiple values ‘*, *’, but only one is allowed. cors error not resolving

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.