C# – Convert a list to a dictionary

The simplest way to convert a list to a dictionary is to use the Linq ToDictionary() method: This loops through the list and uses the key/element selector lambdas you passed in to build the dictionary. In this article, I’ll go into details about how to use ToDictionary() and show how to deal with duplicate keys. … Read more

C# – Search XML for elements, values, and attributes

The simplest way to search XML is to use the Linq-to-XML API in .NET (in System.Xml.Linq). This parses XML and allows you to perform Linq queries on it. Here’s an example: This outputs: XElement is the main class. You use it in combination with Linq methods to perform searches. In this article, I’ll how to … Read more