Witam.
Mam pewien problem dotyczący list w C#. Nie jestem w stanie zrozumieć w jakiej kolejności i co wykonuje program. Sprawdziłem sobie w kompilatorze wyniki (10, 5, 0), ale nie mogę przyswoić sobie tego w jakiej kolejności czego dokonuje program..
using System.IO;
using System;
class Lista
{
public int x;
public Lista next;
public void add(int i)
{
if (next == null)
{
next = new Lista();
next.x = i;
next.next = null;
}
else next.add(i);
}
public void usun()
{
//..............
}
public void pp()
{
if (next != null)
next.pp();
Console.WriteLine("{0}", x);
}
}
class Program
{
static void Main(string[] args)
{
Lista ll = new Lista();
ll.x = 0; ll.next = null;
ll.add(5); ll.add(10);
ll.usun();
ll.pp();
Console.ReadKey();
}
}
zamiana znacznika <code class="c#"> na <code class="csharp"> - fp