"Expression cannot contain lambda expressions" - Exception

13,830

Although it doesn't directly solve your problem, why don't you let the Split method handle the part you are trying to solve through the lambda expressions at the end?

var lastNonEmptySourceEntries = LatestNews.Select(x => x.Source.Split( new []{'/'}, StringSplitOptions.RemoveEmptyEntries).LastOrDefault());
Share:
13,830
kartal
Author by

kartal

Updated on June 04, 2022

Comments

  • kartal
    kartal almost 2 years

    I tried to select and split a list from list of object like this :

    GlobalV.LatestNews.Select(x => x.Source.Split('/').ToList().FindLast(y=> y!="")).ToList();
    

    but I got an exception in FindLast(y=> y!="") said

    expression cannot contain lambda expressions

    I don't understand why !!!? I tried RemoveAll and ..etc but I got the same exception in each time.