Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

csharp(CS8600)

I'm getting the error CS8600 (Converting null literal or possible null value to non-nullable type.) And I don't know why. Here is a snippet of the code and context:

Random rng = new Random();

        Random dmg = new Random();

        string[] monsters = {"skeleton", "goblin", "zombie"};

        int[] monstersHealth = {3, 2, 5};

        int monsterPicked = rng.Next(0, 3);

        int monsterPickedHealth = monstersHealth[monsterPicked];

        string monsterName = monsters[monsterPicked];

        Console.Write("You adventure down a cave, and find a " + monsterName + " blocking your path!\n");

        Console.Write("What would you like to do?\n Attack, Guard, Run\n");

        string fightCommand = Console.ReadLine();

        Console.Write("You wrote " + fightCommand + "!");

        if (fightCommand == "attack" || fightCommand == "Attack")

        {

            int damage = dmg.Next(1, 4);

            Console.Write("You use your trusty wooden sword to attack the " + monsterName + ".\nYou do " + damage + " damage!\n");

            int result1 = monsterPickedHealth - damage;

            Console.Write("The " + monsterName + " has " + result1 + " health left!");

           

           

        }


Wow that's a lot

Sign In or Register to comment.