System.Array. does not contain a definition for “ToList”

后端 未结 5 2130
南方客
南方客 2021-02-11 14:23

I\'m getting the above error on the ToList() line of the code below

if (emailReplyTo != null)
{
  System.Collections.Generic.List replyto
    = ema         


        
5条回答
  •  梦如初夏
    2021-02-11 15:02

    In case someone stumbles on this questions after googling...

    I had the exact same problem in Razor views and adding using System.Linq at the top didn't help.

    What did help is calling .Cast() before using Linq extension methods:

    myArrayVariable.Cast().ToList() //ok, NOW ToList works fine
    

提交回复
热议问题