public myNode(int val, myNode next)
public void SetVal(int val)
public void SetNext(myNode next)
public class myNodeManage
public void Insert(myNode item)
if (count == 0 && item != null)
else if (count > 0 && item != null)
if (Head != null && count > 0)
Console.WriteLine("לא ניתן להוציא עוד חוליה מהשרשרת חוליות ");
public bool Search(int x)
if (temp.GetVal() == x) return true;
public override string ToString()
string str = "NodeManage : \n";
str += " " + temp.GetVal();
public static void Main(string[] args)
myNodeManage nm = new myNodeManage();
for (int i = 1; i < 5; i++)
nm.Insert(new myNode(i, null));
myNode n1 = new myNode(28, null);
myNode n2 = new myNode(18, n1);
myNode n3 = new myNode(16, n2);
myNode n4 = new myNode(28, n3);
Random rnd = new Random();
while (temp.GetNext() != null)
temp.SetVal(rnd.Next(20));
while (temp.GetNext() != null)
Console.WriteLine(temp.GetVal());