C# 「非ジェネリック 種類 ‘IEnumerable’ は型引数と一緒には使用できません。 」が発生した場合の対処法

  • 作成日 2021.12.11
  • 更新日 2022.03.03
  • C#
C# 「非ジェネリック 種類 ‘IEnumerable’ は型引数と一緒には使用できません。 」が発生した場合の対処法

C#で、「非ジェネリック 種類 ‘IEnumerable’ は型引数と一緒には使用できません。 」が発生した場合の対処法を記述してます。

環境

  • OS windows10 pro 64bit
  • VSCODE 1.56.2
  • .NET Core 3.1.409

エラー全文

以下のコードで発生

using System.Collections;

namespace Book.Services
{
    public interface IBookService{
        IEnumerable<int> GetBooks();
    }
}

対処法

「System.Collections.Generic」を使用する

using System.Collections.Generic;

namespace Book.Services
{
    public interface IBookService{
        IEnumerable<int> GetBooks();
    }
}