Browse by Tags
All Tags »
LINQ (
RSS)
If you are using XML in a WinForms application you may find the need to display the XML data in a DataGridView. Let's take this XML: <states> <state name="California"> ...
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...
I have an XML string as follows: <States> <State name="Wisconsin"> <Regions> <Region name="Milwaukee"> <Area...
Another use of anonymous types is for processing directories or files. For example, your application needs to collect a set of files and then process them based on a subset of the file properties. [To begin with an overview of anonymous types, start here...
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...
Similar to my prior post here that details how to use anonymous types to display word counts, this post details how to track information on the physical lines that contain each word. Again, this specific task is more like a homework assignment than a...
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...
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...
If you are using Visual Studio 2008 (.NET Framework 3.5) or newer, you can leverage inferred typing. Inferred typing allows the compiler to infer your data types instead of you having to explicitly define the type. Variables that use inferred typing are...
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...
This entry details the implementation of the ZodiacSigns class from this example in C#: public class ZodiacSigns : List<ZodiacSign> { } Constructor The following is the constructor defined in the ZodiacSigns class: public ZodiacSigns() { ...
Defining a list of integers in your code involves lots of tedious typing. In VB, you can’t do this: 'Dim numberList As new List(Of Integer) = {1, 2, 3, 4, 5, 6, 7, 8, 9} So you have to either add numbers to the list manually, or create an array, which...
One of my favorite features in VB 9 (Visual Studio 2008) is XML Literals. This example demonstrates how insanely easy it is to build an XML file using VB. This code builds XML from a list of customers. Dim customerXml As XElement = _ <customers>...