Get value from a List of Dictionary based on a Key value

I have a List of Dictionary<String, Object>. Like Below:

[ {{“Name”, “Rahul”}, {“Age”, “26”}}, {{“Name”, “Ashish”}, {“Age”, “25”}}, {{“Name”, “Sachin”}, {“Age”, “24”}} ]

Now what I need to do is to get the value of key ‘Name’ where ‘Age’ is 25.

Thanks for your response in advance.

Hi @Himanshu_Punj

You can use the following query:

dictList.Where(Function(dict) dict("Age").ToString() = "25").Select(Function(dict) dict("Name").ToString()).FirstOrDefault()

Hope this helps,
Best Regards.

1 Like

@arjunshenoy working fine. Thanks a lot.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.