Someone linked to http://golf.shinh.org/p.rb?FizzBuzz today and I couldn’t help but have a go. Currently I’m ranked 20 in the C# solutions, but I just can’t seem to shave off those last few characters. [The following code is obviously unminified] class X { static void Main() { for (int i=0; i 0 ? null : “Buzz”; [...]
Mono 2.6 has just been released and can be downloaded from their website. I’ve been using Mono for several months now on my MacBook, and it’s been surprisingly useful. Not only is it an implementation of the C# compiler, .NET runtime and Base Class Libraries, they also have a collection of their own utility libraries. [...]
Recently I’ve had need of a stream data structure – a queue of a certain size that you can keep adding items too and, if the queue gets full, it removes the oldest item. It took me far too long to work it out, so I decided to post the code in case I ever [...]
Over on StackOverflow someone posted a comment with a micro-benchmark on the speed of fields vs. properties. One would expect because the getters and setters of the properties are very small (3-4 IL instructions) that they would be inlined by the JITer and it would make no difference. However, running the following test (modified from [...]
I discovered today that the built in value types (int, float, string etc.) have constructors. Well, why wouldn’t they? Most of them are pointless, parameterises constructors like that for int. However, string has a few useful ones. StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i += 1) { sb.Append(c); [...]
A while ago on Code Project I wrote an article on how to create a tasktray application – that is applications that start and sit primarily in the tasktray. I recently turned it into a Visual Studio template which you can find here. Place the zip file (don’t unpack it) into %my documents%\Visual Studio 2008\Templates\ProjectTemplates\Visual [...]
The addition of generics to C# 2.0 is one of the best things about the language, as is the addition of Linq to C# 3.0 which uses it. However, there are plenty of old API’s out there which predate the addition of generics or are COM libraries which don’t have generics support. What if we [...]
One of the things that first struck me about Scott Hansleman’s BabySmash was the limited range of characters it accepted. Having added more I’m thinking this may have been a wise decision, but we’ll discuss that later. We’re programmers, this presents a challenge and by gum we’re going so solve it whether it’s a good [...]
Jason Kemp made some excellent improvements to the Baby Smash! Options dialog as part of a community project Scott Hanselman is undertaking in order to improve his and readers WPF skills. As excellent as it is, I still feel it could do with some improvements. Most of them are nitpicks mind you, which just goes [...]
Channel 9 has a very good interview with the Spec# team (as does Hansleminutes). For those of you who don’t know Spec# is a superset of C# which mainly adds non-nullable reference types and stronger contracts with pre and post conditions as well as invariants. Before you go and watch the video I’ve got a [...]