I’m working on my own little game where I need a seed generator. I got the random part down and when I have if statements to find exactly one of the input numbers it decides to work for length(placeholder) but when I try to do it for enemy(placeholder) It decides not to output it. I get no error code and if I change where it is in the code nothing changes.
At this point, I’m lost in what to do and this is my last cry for help. https://github.com/ogga-bogga/Random-Seed-Generator-/tree/main
https://docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/arithmetic-operators#division-operator-
https://docs.microsoft.com/en-us/dotnet/api/system.random#Multiple
https://docs.microsoft.com/en-us/dotnet/csharp/how-to/concatenate-multiple-strings
Ditch the mass of if
statements and just output:
If you still want to make sure it’s between 1 and 99 inclusive, then do an if
check like:
As to why your enemy
isn’t outputting, it’s because it’s a negative number.
Your call here: Console.WriteLine(Math.Abs(enemy));
Makes me think perhaps you intended to force enemy
to be positive always. Abs
won’t change the enemy
variable itself, just its output there when called. If you wanted to replace it with a positive version do this reassignment:
enemy = Math.Abs(enemy);
Thanks for the help I just had no clue and felt kinda dumb you did help clean a lot of the mess and fix my issue
C# devs
null reference exceptions