Tuesday, April 5, 2011

return a single list property List in Linq

I am having an issue here i have a list

this.Ddown having 3 properties

i want to write a Linq Query to return one of the property lets say i have property a,b,c

i want to retutn list(c)

how do i do that in linq

From stackoverflow
  • var cList = (from record in this.Ddown
                 select record.c).ToList();
    
  • var listOfC = this.Ddown.Select(x => x.c).ToList();
    
  • Think I got this syntaxed right,

    var listOfC = (from x in this.Ddown
                   select x.c).ToList()
    

0 comments:

Post a Comment