title: CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference? in c#
body: <p>I am working on c# and am beginner. I am under a situation that I am creating Huffman tree where I calculate the frequency of the symbols in a binary file (I mean number of times the symbol repeats is the frequency).I tried to make this "symbol" work for all data types like <code>int</code>, <code>short</code>,<code>ulong</code> etc. I do so using generics.</p>
  
  <p>And I then I tried to run the code I am getting 4 errors like :</p>
  
  <pre><code>CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference?
  </code></pre>
  
  <p>I know compiler is not able to recognize this "<code>T</code>" but before "<code>T</code>" I was using just <code>public class Node&lt;K&gt;</code> instead of <code>public class Node&lt;T&gt; where T : K</code> so that time the error was :</p>
  
  <pre><code>z.cs(13,23): warning CS0693: Type parameter `K' has the same name as the type parameter from outer type `shekhar_final_version_Csharp.Huffman&lt;K&gt;'
  z.cs(10,18): (Location of the symbol related to previous warning)
  </code></pre>
  
  <p>So I was obliged to replace this "<code>K</code>" with equivalent "<code>T</code>". But now the error grown to be 4 (similar):</p>
  
  <pre><code>z.cs(20,21): error CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference?
  z.cs(72,38): error CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference?
  z.cs(83,21): error CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference?
  z.cs(267,40): error CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference?
  </code></pre>
  
  <p>My full code is:</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  public class Huffman&lt;K&gt; where K :  IComparable&lt;K&gt;
  {
      public int data_size, length, i, is_there;
  Line 13: public class Node&lt;T&gt; where T : K
      {
          public Node&lt;T&gt; next, left, right;
          public K symbol;
          public int freq;
          public int is_processed;
      }
  Line 20: public Node&lt;T&gt; front, rear;
      ///////////////////////////////////////////////
      public Huffman(string[] args) 
      {
          front = null;
          rear = null;
          using(var stream = new BinaryReader(System.IO.File.OpenRead(args[0]))) 
          {
              while (stream.BaseStream.Position &lt; stream.BaseStream.Length) 
              {
                  int processingValue = stream.ReadByte(); 
                  {
                      Node&lt;T&gt; pt, temp;
                      bool is_there = false;
                      pt = front;
                      while (pt != null) 
                      {
                          if (pt.symbol == processingValue) 
                          {
                              pt.freq++;
                              is_there = true;
  
                              break;
                          }
                          temp = pt;
                          pt = pt.next;
                      }
                      if (is_there == false) 
                      {
                          temp = new Node&lt;T&gt;();
                          temp.symbol = processingValue;
                          temp.freq = 1;
                          temp.left = null;
                          temp.right = null;
                          temp.next = null;
                          temp.is_processed = 0;
                          if (front == null) 
                          {
                              front = temp;
                          } 
                          else 
                          {
                              temp.next = front;
                              front = temp;
                          }
                      }
                  }
              }
              stream.Close();
              //////////////////////////////
          }
      }
  }
  </code></pre>
  
  <p>Could some one please help me in removing these errors ? I would really appreciate. But please remember if I do "<code>public class Node&lt;K&gt;</code>" instead of  "<code>public class Node&lt;T&gt; where T : K</code>" in Line 13. It gives these errors:</p>
  
  <pre><code>z.cs(13,23): warning CS0693: Type parameter `K' has the same name as the type parameter from outer type `shekhar_final_version_Csharp.Huffman&lt;K&gt;'
  z.cs(10,18): (Location of the symbol related to previous warning) 
  </code></pre>