How do you sort a dictionary by value?

Posted by Editorial Staff | Updated on

If you want to sort a dictionary by value? Use the following c# code:

Since you’re targeting .NET 2.0 or above, you can simplify this into lambda syntax — it’s equivalent, but shorter. If you’re targeting .NET 2.0 you can only use this syntax if you’re using the compiler from Visual Studio 2008 (or above).

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers