Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,
I am passing an array as a parameter to my Action method in controller like
C#
public ActionResult SearchDetails( string val)
  {
   var json = val;
   Dictionary<string,int>[] obj =      JsonConvert.DeserializeObject<dictionary><string,>[]>(json);
     }


my object contains the values in the format{id:1}{id:2} I want to retrieve only all "values"(no need to retrieve "Key" value) from my dictionary object using Linq query
how can i retrieve those values
Posted
Updated 16-Aug-12 18:22pm
v2

You do not need to use LINQ query to do this. Dictionary class already provides Values property which is ValueCollection.
 
Share this answer
 
Comments
AmitGajjar 17-Aug-12 1:27am    
nice answer. you are right LINQ is not required. 5+
C#
var dictValues = obj.SelectMany(x => x.Values);
 
Share this answer
 
Comments
dan!sh 17-Aug-12 1:38am    
Why would you do this? See my reply.
Kuthuparakkal 17-Aug-12 1:41am    
the author of the question asked "how to do this with Linq"
dan!sh 17-Aug-12 1:44am    
His intentions of using LINQ do not seem to have any basis (at least OP did not mentioned them). As a community, IMHO, we should not just blindly answer but also try in improve things.
Kuthuparakkal 17-Aug-12 2:03am    
I am not an astrologer to guess his emotions, intensions or its basis, if you do so go ahead, who stops you...
dan!sh 17-Aug-12 2:05am    
Neither am I but if something is so obvious, isn't it at least worth mentioning?

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