C# refcard now available (free) from DZone

Just a quick announcement. I’ve been working on a C# “refcard” with DZone, and it’s now available. It’s free to download after registration, and covers (briefly): String escape sequences Delegate and event syntax Nullable value types Syntax for generics Extension methods Query expressions Obviously this isn’t meant to be a comprehensive guide to C#, but I picked topics which have elements of syntax which are easily forgotten. Hopefully you’ll find it useful – and a refcard on “Core .NET” will be following fairly soon. DZone also has a discount on Manning books, including C# in Depth.

Thank you, JetBrains: dotTrace rocks

One thing I failed to mention in my post about making reflection perform better is how I optimised the rest of the code. It was always pretty obvious that the reflection side would start off as a bottleneck – but for the rest of the code, I’ve relied heavily on dotTrace. It’s from JetBrains, the same people who make ReSharper (without which I’d be considerably more frustrated with Visual Studio). While there are certainly elements of dotTrace which I haven’t explored (and occasionally some results which have mystified me – such as a claim that the CPU spent 111 seconds … Continue reading Thank you, JetBrains: dotTrace rocks

Making reflection fly and exploring delegates

Background I’ve recently been doing some optimisation work which has proved quite interesting in terms of working with reflection. My efforts porting Google’s Protocol Buffers are now pretty complete in terms of functionality, so I’ve been looking at improving the performance. The basic idea is that you specify your data types in a .proto file, and then generate C# from that. The generated C# allows you to manipulate the data, and serialize/deserialize it. When you generate the code, it can be optimised either for size or speed. The “small” code can end up being much smaller than the “fast” code … Continue reading Making reflection fly and exploring delegates

Making the most of generic type inference

Introduction Specifying type arguments for generic types and methods can be a pain, especially when there are multiple type parameters involved. For instance, imagine having to explicitly specify TOuter, TInner, TKey and TResult for a call to Enumerable.Join! Fortunately the compiler can work out the type arguments most of the time – but only for generic methods. It doesn’t do anything for generic types. However, all is not lost… Overloading type names by number of type parameters One feature of C# and .NET which isn’t used terribly often (in my experience) is the ability to use the same type name … Continue reading Making the most of generic type inference

Book review: Accelerated C# 2008 by Trey Nash

Time for another book review, and this time it’s a due to a recommendation from a reader who has this one, C# in Depth and Head First C#. Resources Amazon Barnes and Noble Publisher’s page (Apress) Introduction and disclaimer My normal book review disclaimer applies, but probably more so than ever before. Yes, Accelerated C# 2008 is a competitor to C# in Depth. They’re different in many ways, but many people would no doubt be in the target audience for both books. If you meet that criterion, please be aware that as the author of C# in Depth I can’t … Continue reading Book review: Accelerated C# 2008 by Trey Nash