Browse by Tags

All Tags » CSharp » LINQ » Lambda (RSS)
If you are doing any type of statistical analysis, you probably need to calculate mean, median and mode. There are lots of places on the Web you can find the calculations. This post is different than most in that it uses LINQ and Lambda expressions. Mean...
5 comment(s)
Filed under: , , , , ,
There are often cases where you need to group on multiple properties and potentially sum on others. This post details how to group and sum on multiple properties using lambda expressions. This example uses an Invoice class, since that provides many opportunities...
11 comment(s)
Filed under: , , , , ,
If you retrieve data into a DataTable, it is easy to bind it to a ComboBox. And before Linq, you would filter the DataTable using a DataView. But with Linq, you have some easy to use features for filtering the contents of your ComboBox. First, here is...
A common requirement with an XML file is to find a particular node. If you are targeting the .NET framework 3.5 or higher, you can find the node using Linq to XML or by using Lambda expressions. As with many of my prior XML examples, the XML string is...
3 comment(s)
Filed under: , , , , , ,
In this prior post , I detailed how to build lists of things using a generic List<T>. Once you have a list, you may need to find items in the list. There are several ways to accomplish this, but using lambda expressions is the most concise. [To...
The Enumerable class is new in .NET 3.5 and is part of the System.Linq namespace. It provides a set of static methods that allow you to query any object that implements IEnumerable, basically meaning any object that supports a for/each. This post focuses...
3 comment(s)
Filed under: , , , ,
I have an XML string as follows: <States>   <State name="Wisconsin">     <Regions>       <Region name="Milwaukee">         <Area...
4 comment(s)
Filed under: , , , , , ,
The last several posts have provided examples of using anonymous types. This post backs up a little and provides an introduction if you are not already familiar with anonymous types. If you are familiar with anonymous types and are looking for  more...
7 comment(s)
Filed under: , , , , ,
This may be more of a homework assignment for a programming class than something you would do in your applications, but it is a good example of using anonymous types, which are new in .Net 3.5 in both VB and C#. [To begin with an overview of anonymous...
8 comment(s)
Filed under: , , , , ,
Some of the collections in the Microsoft Office object models implement IEnumerable. The IEnumerable interface provides the ability to perform a for/each against the collection. With .NET 3.5, a Cast extension method of IEnumerable allows you to work...
Last night, my husband (who is also a .NET developer) asked me about sorting a DataTable by user-defined columns. (Yes, we are a pretty exciting couple!) Most developers that work with DataTables know how to sort the DataTable using a DataView.Sort. If...