Blog LogoBlog Logo

Tag: C# 3

All tags

Tip of the day: Using the null-coalescing operator over the conditional operator

I’ve recently been refactoring a lot of code that used the conditional operator and looked something like this: int someValue =...

— 25 Jul 2011

Why should you be returning an IEnumerable

I've seen in many places where a method returns a List<T> (or IList<T> ) when it appears that it may not actually really be required, or even desirable when...

— 19 Jul 2011

Type Inference

Type Inference is a neat feature where the C# compiler can work out itself what type a reference to an object is. While this can be used for the developer to...

— 19 Mar 2010

Lambda cheat sheet

A while ago I wrote about all the new language features of C# 3.0 and it occurred to me that I'd left out a chunk about Lambdas. With LINQ being such an...

— 17 Mar 2010

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...

— 19 Jul 2008

Navigating XML (LINQ to XML series - part 4)

In my last few posts on LINQ to XML ( part 1 , part 2 and part 3 ) I've shown you a starter on navigating around XML data. In this post I'll continue to show...

— 22 Jun 2008

Navigating XML (LINQ to XML series - Part 3)

In my last two posts I've been introducing you to the the new XML classes in .NET 3.5. In this post I'll continue that and show you some...

— 18 May 2008

Crazy Extension Method

Here is an example of a crazy extension method that alters the semantics of method calling. First the extension method: public static class MyExtensions {...

— 16 Apr 2008

Fizz-Buzz in LINQ

This just occurred to me. It is somewhat pointless, but I thought it was interesting: static void Main( string [] args) { var result = from say in Enumerable...

— 16 Apr 2008

Getting values out of XML in .NET 3.5 (LINQ to XML series part 2)

In my last post I gave a brief introduction to some of the new XML classes available in .NET 3.5. In this post I'll continue that introduction by explaining...

— 12 Apr 2008

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...

— 08 Apr 2008

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...

— 24 Feb 2008

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...

— 18 Jun 2007

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,...

— 18 Jun 2007

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;...

— 18 Jun 2007

Extensions Methods

There have been many times a class has needed to be extended, but the additional code just doesn't sit right on the class itself, or I don't have access to the class...

— 18 Jun 2007

Object Initialisers (1)

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...

— 18 Jun 2007

Object Initialisers (2)

Following on from a comment left on my previous post on Object Initialisers, I decided to take a screenshot of Orcas displaying the tooltips. I...

— 18 Jun 2007

Object Initialisers (3)

It seems that now I've got Lutz Roeder's Reflector on the case with Orcas the way object initialisers work slightly different to how I expected. As it was...

— 18 Jun 2007