私は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);
}
}
}