No.
You are declaring a class called Node:
public class Node
{
...
}
Within the class, you declare two fields:
public Node next;
public Object data;
Both fields are declared as
public
which means that all code outside the class can access them, as well as code inside the class.
You have not declared a constructor for the class, which means that an empty default constructor will be used.
The type of the first one is Node - which means it can refer to another instance of a Node - which is what you need to build a linked list: each Node contains a reference to the next node in the chain.
There are a couple of bad ideas here:
next
and
data
should start with an uppercase letter and should really be properties, not fields:
public class Node
{
public Node Next {get; set;}
public object Data {get; set;}
}
You should not expose fields directly, use properties when you can instead.
You also shouldn't really use an
object
to contain your data, that complicates the code when you want to use the Node as you need to check what kind of data it is, and cast it to an appropriate type before you can use it. It's a much, much better idea to use a specific datatype that is appropriate to the data you are going to store in the node, like
int
,
string
, or a class of your construction.