Click here to Skip to main content
15,846,038 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have list of object list1 ,from this list i want to select a List<object> say "obj" with
obj.type="1001"
Please suggest Linq query for this
Posted

I got your problem:

Use the below code:

var
XML
obj = new List<test>();
            var res = obj.FirstOrDefault( x => x.Type = "1001");
            if (res != null)
            {
                //Process result
            }
 
Share this answer
 
First of all there is no extension to object with the name "type"
Here is the LINQ query as close as I can get to what I think you are asking:

XML
var list1 = new List<object>();
list1.Add("Something");
var item = list1.FirstOrDefault(i => i.GetType().ToString() == "System.String");
Console.WriteLine(item.GetType());
Console.ReadLine();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900