LINQ Query Syntax Example

This simple LINQ example shows how I’m using LINQ to access an in memory Employee object. I’m also showing how to see the object type in the event it’s needed. Continue reading


Dictionary Collection With A Custom String Comparer

After working with the dictionary collections, and the string comparers that go with it. I decided to mess around more with the StringComparer class and define my own equality compare class to get an idea of how things work under the hood. This example is taking elements from a list and putting them into three sorted lists. One sorted list without any kind of compare, the second using the build it string compare class, and the third a small custom compare class. Continue reading

Dictionary Collection With A String Comparer

Based on the previous example. What would happen if you had a key value that was uppercase and you executed methods methods with key values in lowercase? You would get an error that the items wasn’t found. Or worse, if adding an item the method would add it. Then you would have multiple elements with the same key value pair. Not a good situation. That’s where the StringComparer class comes in handy when I’ll describe below. Continue reading

Dictionary (TKey, TValue) Collection Example

Here I’ll be explaining some basic usage of the dictionary collection class. Dictionaries are a generic data type that stores values with an associated key. This key is important because it is used for lookup, addition, removing, and indexing of values. The dictionary is intended to be used with any data type as I’ll demonstrate below. What I’ll be doing is creating an object type and storing the type in a dictionary with a key. Then I will perform various tasks on the dictionary like displaying the elements, searching for elements, and removing elements. Continue reading