title: binary tree in C#
body: <p>How would you do a binary tree in C# that is simple, straight forward, and does not use any predefined classes?  I am talking about something simple like you would do in C++</p>
  
  <p>Nothing like NGenerics
  <a href="https://stackoverflow.com/questions/1806511/binary-tree-in-c">Objects that represent trees</a></p>
  
  <p>I mean something that starts with something simple, like this:</p>
  
  <pre><code>struct
  {
    Node * left
    Node * right
    int value;
  }
  </code></pre>
  
  <p>Follow up question:</p>
  
  <p>OK, so if I have this:</p>
  
  <pre><code>public class binarytreeNode
  {
      public binarytreeNode Left;
      public binarytreeNode Right;
      public int data;
  
  }
  </code></pre>
  
  <p>Would I have to put the methods that act upon the node, inside this class?  Doesn't this make this no longer a Node?</p>
  
  <p>If I create a method for adding a node inside the Program class:</p>
  
  <pre><code>class Program
  {       
       public binarytreeNode AddNode(int value)
      {
          binarytreeNode newnode = new binarytreeNode();
          newnode.Left = null;
          newnode.Right = null;
          newnode.data = value;
          return newnode;
      }
       static void Main(string[] args)
      {
          binarytreeNode head = AddNode(4);
  
      }
  }
  </code></pre>
  
  <p>The compiler says that an object reference is required for my call to AddNode.  Why?</p>