C
C#3w ago
blunt

✅ variable wont change

switch(vars.AfterMath)
{
//vars is a class i got w all my variables in it
//AfterMath is a variable that stores if you won or no
case true:
vars.money = vars.money + (vars.betAmount * 2);
break;
case false:
vars.money = vars.money - vars.betAmount;
}
switch(vars.AfterMath)
{
//vars is a class i got w all my variables in it
//AfterMath is a variable that stores if you won or no
case true:
vars.money = vars.money + (vars.betAmount * 2);
break;
case false:
vars.money = vars.money - vars.betAmount;
}
then when I go run the program again it says the money is "100$" as I had it at the start and it wasent changing???
26 Replies
TheRanger
TheRanger3w ago
can u show the declaration of vars.money ?
blunt
bluntOP3w ago
class vars
{
public static int money;
class vars
{
public static int money;
i didnt create instanse
TheRanger
TheRanger3w ago
well maybe vars.betAmount is 0
blunt
bluntOP3w ago
but when i lose it goes down
Angius
Angius3w ago
Also, you're saying "run the program again". Meaning, you close it and re-run it? Or you got some loop that re-runs it?
blunt
bluntOP3w ago
while loop well do while loop thingy
Jimmacle
Jimmacle3w ago
can you share the full program?
blunt
bluntOP3w ago
the file or
Jimmacle
Jimmacle3w ago
$paste
MODiX
MODiX3w ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
blunt
bluntOP3w ago
how do i save it on that website wait nvm
blunt
bluntOP3w ago
BlazeBin - wzqqmlktbsch
A tool for sharing your source code with the world!
blunt
bluntOP3w ago
i have static public main on a different file so dw abt that
TheRanger
TheRanger3w ago
where is vars.money in ur code
blunt
bluntOP3w ago
its chips
TheRanger
TheRanger3w ago
did you make sure the if condition of that code returned true? you can debug, set breakpoints, or even put Console.WriteLine to make sure it was executed
blunt
bluntOP3w ago
i didnt put it as a bool cuz there was a third option when u win but i didnt need to program that bit so i js didnt change it ill try that ty
TheRanger
TheRanger3w ago
well u already did with Console.WriteLine("your number is lower! you lose"); did it print that?
blunt
bluntOP3w ago
it printed it yeah and it is a 0
TheRanger
TheRanger3w ago
what is, vars.betting?
blunt
bluntOP3w ago
bet amount
Angius
Angius3w ago
Your best bet would be to just use the debugger, step through the code, and see when it changes to the incorrect value
blunt
bluntOP3w ago
alr
TheRanger
TheRanger3w ago
$debug
MODiX
MODiX3w ago
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
blunt
bluntOP3w ago
alr tysm yall
Want results from more Discord servers?
Add your server