Home>

The following error message has occurred for this program statement

private void rockButtonpictureBox_Click (object sender, EventArgs e)
{
var hand = JankenHand.Rock;

Image handImage;
if (hand == JankenHand.Rock)
{
handImage = Properties.Resources.rock;

}
else if (hand == JankenHand.Scissrs)
{
handImage = Properties.Resources.scissrs;
}
else else
{
handImage = Properties.Resources.paper;
}
playerHandPictureBox.Image = handImage;

}
: Error code

Error CS0246 The type or namespace name'Randon' was not found (make sure a using directive or assembly reference is specified).
jankenBattle C: \ Users \ noahs \ source \ repos \ jankenBattle \ jankenBattle \ MainForm.cs 45 Active

Error CS0117'Resources' does not have a definition for'paper'
jankenBattleC: \ Users \ noahs \ source \ repos \ jankenBattle \ jankenBattle \ MainForm.cs 40 Active

Error CS0117'Resources' does not have definition of'rock'jankenBattle C: \ Users \ noahs \ source \ repos \ jankenBattle \ jankenBattle \ MainForm.cs 32 Active

Error CS0117'Resources' does not have definition of'scissrs' jankenBattle C: \ Users \ noahs \ source \ repos \ jankenBattle \ jankenBattle \ MainForm.cs 36 Active

It seems that the Image variable "handImage" is involved, but I'm not very familiar with this either.

  • Answer # 1

    Answer as C # code from the file name of the error message.

    RandonIsRandomIs a mistake. In the part not shown here (near the beginning of the source file)using System;If there is one line that says, the part not shown here (somewhere in the source file)RandonWhere it saysRandomIf you fix it to, this error should disappear.

    The remaining errors are due to the resources for the three types of images not yet being registered or having different names and not being found.
    You're entering the code while looking at something (book or website), right?Contents written before thatMake sure you haven't overlooked it.

  • Answer # 2

    Error CS0246 The type or namespace name'Randon' was not found (make sure a using directive or assembly reference is specified).

    It says that the name Randon doesn't make sense, so let's check it out.

    # Random?