In C# fields of a class are private by default
class Node
{
public int snakeHead ; // points to another node where the player goes down to
public int ladderFoot; // points to another node where to player goes up to
}
Just making your fields public should fix your issue.
EDIT: using best practices you would keep fields private, but create properties and use them to deal with your data. Also naming private with an underscore is a common practice:
class Node
{
private int _snakeHead ; // points to another node where the player goes down to
public int SnakeHead
{
get {return _snakeHead;}
set {_snakeHead = value;}
}
private int _ladderFoot; // points to another node where to player goes up to
public int LadderFoot
{
get {return _ladderFoot;}
set {_ladderFoot = value;}
}
}
3
solved Why can’t you access parts of a class in C# like you could a struct in C++? [closed]