❔ issues with variable
I have this variable called "remChar"
var remChar = Console.ReadLine().ToUpper();
while (remChar == "YES" || remChar == "Y")
I want to access the variable later on in the while loop so I can change the information in the variable to look for if it says "No", but when I try to implement it into the code it says " A local or parameter named 'remChar' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter"
How would I go by using the variable later on in the code?
thank you :)
7 Replies
sounds like you tried to redeclare the variable
i.e. you wrote
var remChar = newValue;
instead of remChar = newValue;
thinker227#5176
REPL Result: Failure
Exception: CompilationErrorException
Compile: 497.764ms | Execution: 0.000ms | React with ❌ to remove this embed.
thinker227#5176
REPL Result: Success
Compile: 533.056ms | Execution: 30.773ms | React with ❌ to remove this embed.
is it possible just to use the variable again? because i tried to do remChar(); and it had an error
"Method name expected"
well
remChar
isn't a method
so you can't call it using ()
You can use the variable again by just assigning it a new value.thank you! this fixed my problem
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.