Tip of the Day #7 (SysInternals)

I’ve visited the SysInternals site a few times over the course of my career because of some strange problem that I just couldn’t track down. The amount of information about what is actually happening on your system that the SysInternals tools provide is phenomenal. The site was run by Mark Russinovich and Bryce Cogswell until …

Monitoring change in XML data (LINQ to XML series – Part 5)

This is the 5th part in a series on LINQ to XML. In this instalment we will look at monitoring changes in XML data in the XML classes added to .NET 3.5. The XObject class (from which XElement and XAttribute, among others) contains two events that are of interest to anyone wanting to know about …

Tip of the Day #4 (Connection Strings in Config files)

From .NET 2.0 onwards a new and improved configuration management system has been put in place. You can now add a <connectionString> element to the config file and use it to place the connection strings to the database and then retrieve then in a consistent way in your application. It supports multiple connection strings too …

Functional Programming in C#3.0

Oliver Sturm spoke to to Scottish Developers in Glasgow earlier this week to a packed room! His topic was Functional programming in C# 3.0. The feedback was overwhelmingly positive and he received comments such as “Great code examples” and “very worthwhile”. So, if you missed last nights session, or you just want to review the …

Introduction to LINQ to XML

Last year I wrote about the new languages features available in C# 3.0 (Anonymous Types, Extension Methods, Automatic Properties, A start on LINQ, Object Initialisers I, Object Initialisers II, & Object Initialisers III) and since then I’ve really got in to LINQ, especially LINQ to XML. The reason for that is that I hate XPath …

Mixins in C# 3.0

This is something I’ve been mulling around in my head for a few days now. “Out of the box” C# 3.0 does not support mixins, but I think you can get some of the abilities of a mixin with what is there already. Firstly I should probably explain what a mixin is. A mixin is …

Creating Many-to-Many joins

A topic that comes up from time to time in forums is how to join two tables together when there is a many-to-many relationship. Typical examples include teachers-to-students or articles-to-tags (to create a “tag cloud”) If you have made any relationships in a database you will see that it is very easy to create a …

Oh No! More on SQL Injection Attacks

I’ve not written about this in a while becuase it seemed that people were getting the message. But today I was asked, on Code Project, “I am wondering why injecting values into the [SQL] string is considered a security risk?” Here is my response: Because if you inject strings into the SQL, especially ones that …

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 …