More Than Nothing

“You mean you can't take less; it's very easy to take more than nothing.”

Archive for the ‘C#’ Category

FizzBuzz Golf

Posted on September 10, 2011 by [ICR] under C#, golf, Programming

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”; [...]

No Comments | Read the rest of this entry »

Mono 2.6

Posted on December 16, 2009 by [ICR] under .NET, C#, Programming

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

1 Comment | Read the rest of this entry »

Stream Data Structure

Posted on February 25, 2009 by [ICR] under .NET, C#, Programming

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

1 Comment | Read the rest of this entry »

Make sure you know what you're measuring

Posted on December 15, 2008 by [ICR] under .NET, C#, Programming

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

No Comments | Read the rest of this entry »

Discovery of the Day – Constructors on a string

Posted on October 11, 2008 by [ICR] under .NET, C#, Programming

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); [...]

No Comments | Read the rest of this entry »

Tasktray Applications

Posted on August 18, 2008 by [ICR] under .NET, C#, Programming

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

No Comments | Read the rest of this entry »

Using Cast to add Linqy goodness to old API's

Posted on August 15, 2008 by [ICR] under .NET, C#, Programming

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

No Comments | Read the rest of this entry »

BabySmash – Adding more characters

Posted on June 14, 2008 by [ICR] under C#, Programming, WPF

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

No Comments | Read the rest of this entry »

Improving the Improvements – Cleaning up and adding validation to Baby Smash! Options

Posted on June 3, 2008 by [ICR] under .NET, C#, Programming, WPF

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

1 Comment | Read the rest of this entry »

The benefit of strong contracts in Spec#

Posted on May 29, 2008 by [ICR] under C#, Programming, Spec#

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

No Comments | Read the rest of this entry »