C# Properties Problem

Started by
2 comments, last by Xolution 21 years, 9 months ago
The code speaks for itself...
  
    ListNode ln1 = new ListNode("1");
    ListNode ln2 = new ListNode("2");
    ln1.Next = ln2;
    Console.WriteLine(ln1.Content);
    Console.WriteLine(ln2.Content);
    Console.WriteLine(ln1.Next.Content);  // Dies here.

  
Content is a string property of ListNode, Next is a ListNode property of ListNode (next node in the list). Any ideas? [edited by - Xolution on June 30, 2002 7:43:28 PM]
/bin/finger that girl in the back row of machines
Advertisement
What the code for the Next property look like? What about other (relevant) bits of ListNode? I assume you wrote ListNode yourself...

codeka.com - Just click it.
Ah, no worries now.
I had my set part like

set {
this._next = Next;
}

Changed it to value, now it all seems to work...
/bin/finger that girl in the back row of machines
I think Eric Gunnerson mentioned something about making that a compiler error - at least this variant:

  public SomeType SomeThing{   get{ return SomeThing; } //instead of someThing - the private instance variable}  
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

This topic is closed to new replies.

Advertisement