samedi 13 novembre 2021

" Operator '&&' cannot be applied to operands of type 'bool' and 'lambda expression' " error being output when creating an if statement [closed]

        Random dieValue = new Random();
        int die1 = dieValue.Next(1, 7);
        int die2 = dieValue.Next(1, 7);
        int dieTotal = die1 + die2;
        int points = 0;
        if((dieTotal <= 6) && (dieTotal => 3)){
            points = 5;
        }

This is my code, I am trying to create a program that outputs different points based on what the randomly generated die produces. I am going to use more else if statements for different numbers but I am running into the error code: "Operator '&&' cannot be applied to operands of type 'bool' and 'lambda expression'" I have tried it with and without the () around the calculations to no success. I am a beginner when it comes to coding and am currently in my first year of university so for knowledge's sake I would like to know how to fix this and why this error has occurred and why the fix that you provide works if possible. Many thanks!

Aucun commentaire:

Enregistrer un commentaire