I am trying to build kinda dynamic array. When trying to assign the array's last space the ignite property's set method creates a node and assigns this node's next reference. That's what I am thinking.
But this set method not even working and I am getting an IndexOutOfRangeException error. What is the problem? Is it possible?
(My English is not good - sorry for this)
public class DynamicArray
{
public static int index = 0;
public Node head;
public static Node last;
public DynamicArray()
{
head = new Node();
}
public class Node
{
public object[] datas = new object[10];
private object ignite = new object();
public Node? next;
public object Ignite
{
get
{
return ignite;
}
set
{
next = new Node();
ignite = value;
}
}
public Node()
{
datas[9] = Ignite;
last = this;
index = 0;
}
}
public void Add(object data)
{
last.datas[index] = data;
index++;
}
}