Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, the first compiler error I get is that it complains that:</p> <blockquote> <p>Using the generic type 'System.Collections.Generic.IEnumerator' requires '1' type arguments</p> </blockquote> <p>This is on line 16, this one:</p> <pre><code>IEnumerator IEnumerable.GetEnumerator() </code></pre> <p>Fixing that by adding a using directive for the <code>System.Collections</code> namespace (tip: place the cursor just after IEnumerator, on the <em>r</em> at the end of the word, and hit Ctrl+. (ctrl + the dot-key), it should suggest you add a "using System.Collections;" directive, do that).</p> <p>Then it compiles, and runs. Does that match what you expect?</p> <p>Also, note that you should always post the actual error messages you're getting, this way we're not barking up the wrong tree if there's something else wrong with your code that we're not seeing at first glance.</p> <p>Additionally, you can simplify this very common implementation of <code>IEnumerable&lt;T&gt;</code> by calling one of the methods from the other, hence I would simplify the implementation of the second methods like this:</p> <pre><code>IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); // this will return the one // available through the object reference // ie. "IEnumerator&lt;int&gt; GetEnumerator" } </code></pre> <p>this way you only implement the actual enumerator code once.</p> <p>And finally see <a href="https://stackoverflow.com/users/27423/earwicker">Earwicker</a>'s <a href="https://stackoverflow.com/questions/1174713/ienumerablet-in-c/1174736#1174736">answer</a> as well, it shows a better (in my opinion at least) way to write this whole code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload