1

私はSquares、インターネットにすでに存在していたこの拡張メソッドを見ていました。このコンパイルを取得できませんでした。コンパイラは、 「非ジェネリック型 `System.Collections.IEnumerable' は型引数とともに使用できません」 のようなレポートを返します。

以下のこのコードの何が問題なのですか?

どんな助けでも大歓迎です。

using System.IO;
using System;
using System.Collections;

static class Program {

     static IEnumerable<int> Squares (this int from, int to) {
        for (int i=from;i<=to;i++)
        {
            yield return (int)i*i;
        }
    }

    static void Main(string[] args)
    {
        var min=1;
        foreach (int i in min.Squares(4))
        {
            Console.WriteLine(i);
        }
    }
}
4

1 に答える 1

13

に置き換えusing System.Collections;ますusing System.Collections.Generic;

于 2013-10-16T08:20:29.773 に答える