Following on from Gary Short‘s message from my previous post on Object Initialisers, I decided to take a screenshot of Orcas displaying the tooltips. I really have to compliment those that designed and wrote intellisense. Not only does it work with object initialisers, but it is intelligent enough to remove properties that have already be …
Tag Archives: C#
Object Initialisers I
Continuing with the language enhancements in C#3.0. This post presents the concept of object initailisation. Say you have a class with a default constructor and lots of properties and you want to be able in initialise the object in one line but the class doesn’t support it. What you can do is use object initailisers: …
A start on LINQ
I was at the Microsoft MSDN Roadshow today and I got to see some of the latest technologies being demonstrated for the first time and I’m impressed. Daniel Moth’s presentation on the Language Enhancements and LINQ was exceptional – It really made me want to be able to use that technology now. What was interesting …
Automatic Properties
Continuing my look at the new features found in the C# 3.0 compiler I will look at Automatic Properties. public class Employee{ public string FirstName { get; set; } public string Surname { get; set; } public DateTime DateOfBirth { get; set; } public Employee Manager { get; set; }} At first look this might …
Extensions Methods
I’ve been looking at more of the language enhancements in C# 3.0. In this post I’m going to look at Extensions. There have been many times went a class has needed to be extended, but the additional code just doesn’t sit right on the class itself. In that case a utility or helper class is …
Anonymous Types
Anonymous Types are another new feature to the C# 3.0 compiler. To create one, just supply the new keyword without a class name, followed by the, also new, object initialiser notation. As the type name is not known it needs to be assigned to a variable declared with the local variable type inference, var, keyword. …
Test Driven Development By Example
Introduction A lot has been written on the subject of test driven development, and especially on the idea that tests ought to be written first. This is an ideal that I strive for, however, I have a tendency to write the unit tests afterwards. Some people learn better by example. This article, rather than going …
How to get a list of all subdirectories
This is an example of how to obtain a list of all subdirectories using a recursive method with the .NET Framework. public static List GetSubdirectories(DirectoryInfo directory) { // Set up the result of the method. List<DirectoryInfo> result = new List<DirectoryInfo>(); // Attempt to get a list of immediate child directories from the directory // that …
Passing Values Between Forms in .NET
Introduction I wrote this article in response to an almost overwhelming number of requests on forums on how to pass a variable from a one Windows Form to another. In fact, saying that it is going between one form and another is somewhat of a misnomer because this will work for any type of object …