Question Why variable isn't updating even though it's updated in class

Rudyyy

New member
Joined
Dec 26, 2023
Messages
1
Programming Experience
1-3
1703621974418.png
1703622007887.png
1703621954900.png
 
In the future, please post your code in code tags, not as screenshots. It can be difficult to read screenshots on small devices.
 
Anyway, with regards to your problem, look closely at the documentation for Replace():
Returns a new string in which all occurrences of a specified Unicode character or String in the current string are replaced with another specified Unicode character or String.

(emphasis mine)

Notice that it is non-destructive, just like all the other C# string methods. It returns a new string with the modified value instead. You are not doing anything to capture that modified value.
 
Also, there is another dimension of your code as to which we cannot speak to. How does your CommandInterpreter class know that it is supposed to update Program.pathManager? You didn't show us the code for CommandInterpreter. I hope that you aren't using the anti-pattern of using global variables.
 
In the future, please post your code in code tags, not as screenshots. It can be difficult to read screenshots on small devices.

Not just that but we can't copy the code if we want to run it or edit it either. If we want to provide a modified version of your code, we need to type it all out by hand ourselves, which is a big waste of time. DO NOT post a screenshot of code, error messages, etc, unless it provides additional value over and above what the text itself provides. ALWAYS provide the text, formatted appropriately, even when you do post a screenshot.
 

Latest posts

Back
Top Bottom