C
C#2mo 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
TheRanger2mo ago
can u show the declaration of vars.money ?
blunt
bluntOP2mo ago
class vars
{
public static int money;
class vars
{
public static int money;
i didnt create instanse
TheRanger
TheRanger2mo ago
well maybe vars.betAmount is 0
blunt
bluntOP2mo ago
but when i lose it goes down
Angius
Angius2mo 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
bluntOP2mo ago
while loop well do while loop thingy
Jimmacle
Jimmacle2mo ago
can you share the full program?
blunt
bluntOP2mo ago
the file or
Jimmacle
Jimmacle2mo ago
$paste
MODiX
MODiX2mo 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
bluntOP2mo ago
how do i save it on that website wait nvm
blunt
bluntOP2mo ago
BlazeBin - wzqqmlktbsch
A tool for sharing your source code with the world!
blunt
bluntOP2mo ago
i have static public main on a different file so dw abt that
TheRanger
TheRanger2mo ago
where is vars.money in ur code
blunt
bluntOP2mo ago
its chips
TheRanger
TheRanger2mo 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
bluntOP2mo 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
TheRanger2mo ago
well u already did with Console.WriteLine("your number is lower! you lose"); did it print that?
blunt
bluntOP2mo ago
it printed it yeah and it is a 0
TheRanger
TheRanger2mo ago
what is, vars.betting?
blunt
bluntOP2mo ago
bet amount
Angius
Angius2mo 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
bluntOP2mo ago
alr
TheRanger
TheRanger2mo ago
$debug
MODiX
MODiX2mo 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
bluntOP2mo ago
alr tysm yall
Want results from more Discord servers?
Add your server