title: Cast LinkedList<int> to Queue<int>
body: <p>I have an assignment where I'm required to create a queue and fill it with consecutive integers.  Another requirement of the assignment is that when I construct a Queue object, I must allocate a new LinkedList, but store it in a Queue variable.</p>
  
  <p>The sample code below illustrates the above in my constructor.  It fails to compile because of the following error:</p>
  
  <blockquote>
    <p>Error CS0030  Cannot convert type 'System.Collections.Generic.LinkedList' to 'System.Collections.Generic.Queue'</p>
  </blockquote>
  
  <p>Can someone please propose the changes I need to make in my constructor to initialize these variables?  Include an additional example how I'd "add" an item to the queue as well please.</p>
  
  <p>..........................</p>
  
  <pre><code>class Sieve
  {
      public Queue&lt;int&gt; qSource;
      public Queue&lt;int&gt; qPrime;
  
      public Sieve()
      {
          qSource = (Queue&lt;int&gt;)new LinkedList&lt;int&gt;();
          qPrime = (Queue&lt;int&gt;)new LinkedList&lt;int&gt;();
      }
  
      public int Count { get; set; }
      public int Max { get; set; }
  }
  </code></pre>
  
  <hr>
  
  <p>The assignment verbatim outlines the following requirement:</p>
  
  <p>"...You must use a Queue interface. When you construct a Queue object, allocate a new LinkedList, but store it in a Queue variable. The LinkedList class implements the Queue interface. Both should be imported
  from java.util. For example:</p>
  
  <p>Queue myQueue = new LinkedList();</p>
  
  <p>..."</p>
  
  <p>Do note that I'm doing the assignment in C# yet it was handed out as a Java assignment.</p>