LINQ: How to declare IEnumerable[AnonymousType]?

后端 未结 6 1839
被撕碎了的回忆
被撕碎了的回忆 2021-02-02 09:34

This is my function:

    private IEnumerable SeachItem(int[] ItemIds)
    {
        using (var reader = File.OpenText(Application.StartupPath + @\"         


        
6条回答
  •  旧时难觅i
    2021-02-02 10:00

    You cannot declare IEnumerable because the type has no (known) name at build time. So if you want to use this type in a function declaration, make it a normal type. Or just modify your query to return a IENumerable and stick with that type.

    Or return IEnumerable> using the following select statement.

    select new KeyValuePair(id, m.Groups[2].Value)
    

提交回复
热议问题