There are many ways to make frameworks and libraries more extensible via pluggable providers. Here is code that shows how to using reflection and custom attributes to find types in an assembly to evaluate expressions in a custom configuration section. This draws upon the concept of ExpressionEvaluators and ExpressionBuilders. Read more...
One of the patterns that came up today in a code review was the Tester-Doer Pattern. One sees this pattern a lot especially when the “doer” side of the equation has a pretty decent performance penalty. Essentially, you test a condition to make sure you need to do the “doer“ operation and pay that penalty. Sometimes this can cause race conditions. Read more...
C# Automatic Properties is just one of a number of new C# 3.0 Features that you can experience during Visual Studio 2008 development. It feels different using the new C# features in an actual web application as opposed to just writing C# tutorials about them. Read more...
In Orcas Beta 2 we will see partial methods, which provides a hook for developers to “inject” code into partial classes without running the risk of that code being overwritten when the class is being generated in the future. Read more...
A compilation of C# 3.0 Examples per many of the C# 3.0 Tutorials I have written to date: Automatically Implemented Properties, Object and Collection Initializers, Query Expressions, Implicity Typed Local Variables, Anonymous Types, Query Expression Translation, Lambda Expressions, and Extension Methods...
The C# 3.0 Specification mentions Expression Trees in C# 3.0, but it doesn't go into much detail and the information provided didn't help me much in trying to understand them. After a little poking around in C#, however, I have a better grasp of Expression Trees. In C# 3.0, you can define a delegate as follows using a lambda expression...
I mentioned the other day that I watched the C# 3.0 video with Eric Lippert and Charlie Calvert where they were talking about getting the C# 3.0 Compiler to work with type inference as needed by LINQ. During the video Eric mentioned that query expressions were syntatical sugar. Here is why...
I have talked about two other C# 3.0 Features thus far: Extension Methods and Lambda Expressions. Another interesting feature in C# 3.0 is Object Initialization Expressions. You can use Object Initialization Expressions in C# 3.0 to create a customer as follows...