C
C#4d ago
qucumberrr

[C# console app .net4.7.2] Seemingly can't instantiate an object

Okay So I'm working on a text based adventure app for an entry level college class. I have an "Alien" base class which is inherited by a "CrabAlien" class, I'm trying to instantiate a crab alien in my "GameWorld" class but it's telling me that none of it exists in the current context and I'm not sure why. I'm sure it's something stupid I'm missing like some sort of permission level thing, but I just can't figure it out
No description
No description
No description
6 Replies
qucumberrr
qucumberrrOP4d ago
and just incase it's also important here are the error codes it's throwing
No description
reflectronic
reflectronic4d ago
code needs to go inside of a method
public class GameWorld
{
public void DoSomething()
{
Alien Alien1 = new CrabAlien();
alien1.isHidden = true;
}
}
public class GameWorld
{
public void DoSomething()
{
Alien Alien1 = new CrabAlien();
alien1.isHidden = true;
}
}
qucumberrr
qucumberrrOP4d ago
oh shit, you're so right thank you been racking my brain on this for like 40mins
Angius
Angius4d ago
As a side note, are you forced to use 4.7?
qucumberrr
qucumberrrOP4d ago
currently yes, and i couldn't tell you why if i wanted to our prof just said "it has what we need for the class"

Did you find this page helpful?