February 24th, 2009
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
Sometimes it is handy to have a quick overview of all the assemblies that your C# program has loaded. Maybe because you are trying to debug a version conflict, or because you want to distribute your application and want to get an idea of its dependencies.
Read the rest of this entry »
Tags: c#, reflection
Posted in Intermediate, Learn C# | 3 Comments - getting there! »
January 7th, 2009
As your application grows it can be useful to get an idea of how much memory a particular data structure is using in memory. Measuring memory in a garbage collected environment is a somewhat of a moving target as the Garbage collector is able to move things around in the background.The .NET libraries offer two ways of measuring your applications memory. The total amount of memory allocated to the process (which includes code, unique libraries) and the amount of memory used that the Garbage collector is aware off (which is only your applications variables). This second set is of course a subset of the total amount of memory.
Read the rest of this entry »
Tags: garbage collector, hack, Learn C#, memory usage, object creation, process
Posted in Intermediate, Learn C# | 1 Comment already!»
January 6th, 2009
The .NET C# library provides all the basic elements for encrypting a string with a passphrase and decrypting it later. Doing this however requires a few steps in between. This post show a simple set of routines to help you do just that. We use the TripleDES encryption suite to do the actual encryption, with a little help from the MD5 hash sum generator.
The complete source code is listed below, but lets have a little look at how it works first.
Read the rest of this entry »
Tags: decryption, encryption, Learn C#, md5, strings
Posted in Intermediate, Learn C# | 11 Comments - getting there! »
December 29th, 2008
As soon as I heard that theĀ MonoDevelop Subversion code included support for actually debugging my C# code I tried installing it to give it a go. Optimistically I kept notes, figuring that it would be useful to write a post about the install process later. As my notes started to turn into a book, and the arrows back and forth and crossed out scribbles increased I gave up on writing the ultimate “ten step guide to installing Monodevelop on Ubuntu”.
When I finally had MonoDevelop compiled and installed — the promised debugging didn’t actually work. Bummer. I gave up, and went back to coding the old way (with ticker tape). This morning I checked out the latest SVN, installed it and ran it, just for laughs.
And behold as shown below — debugging actually worked. I can step and trace through the code, and set watches making MonoDevelop suddenly that much more useful to me.
The best thing? The Mono C# libraries are not black boxes but open source — you can step and trace directly into the Mono libraries themselves and find out what Mono is doing as you call library functions.

The problem with installing MonoDevelop 2.0alpha 2 is that the guides online don’t actually produce a working MonoDevelop installation. If you run MonoDevelop under Ubuntu like I do, the number of dependencies and sub-dependencies you need to resolve is large and I ended up compiling, re-compiling and changing version numbers of modules multiple times to find combinations that worked. In addition I had to change, add and resolve many missing library conflicts within Ubuntu as well.
Concluding: Yes, it is possible. Just do not expect a quick and easy install of MonoDevelop 2.0 alpha 2 on your Ubuntu installation.
This is fun only if you have plenty of spare time.
Some hints — this does not produce a working Mono Develop installation
- Remove Mono 1.9, MonoDevelop 1.0, and any and all other mono related things from your ubuntu installation before attempting to compile MonoDevelop 2.0 Alpha 2 to avoid conflicts down the road.
- Install mono 2.3, the debugger and mono develop from SVN, not from the packages provided on the website (they do not work)
- $ svn co svn://anonsvn.mono-project.com/source/trunk/mono
$ svn co svn://anonsvn.mono-project.com/source/trunk/mcs
$ svn co svn://anonsvn.mono-project.com/source/trunk/debugger
$ svn co svn://anonsvn.mono-project.com/source/trunk/mono-addins
$ svn co svn://anonsvn.mono-project.com/source/trunk/olive
$ svn co svn://anonsvn.mono-project.com/source/trunk/monodevelop
- I installed gtk-sharp-2.12.5, gnome-sharp-2.20.0 and libglade-2.0.1 as support libraries
- Compile and install monodevelop last of all
Mono JIT compiler version 2.3 (/trunk/mono r121276 Thu Dec 11 13:04:53 CST 2008)
Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
Tags: Learn C#, monodevelop
Posted in Intermediate, Learn C# | Comments Off
December 9th, 2008

Hash values have many uses in computing: for storing password tokens, securing that a file hasn’t been tampered with, or to create a short semi-unique signature for a larger data set. A hash algorithm takes a data set — such as a string — and turns it into a numeric value of a certain length.
This article will go into how to create a hash of your passwords and how salting them makes them more secure.
Read the rest of this entry »
Tags: crc, hash, Learn C#, md5, salted, sha-1, sha-256
Posted in Algorithms, Intermediate, Learn C# | 3 Comments - getting there! »
November 27th, 2008

Unit testing helps you verify that each individual part of your code is working as expected and keeps doing that as you change your software. You do this by adding small bits of testing code and have the unit testing frame work execute them in order. I am currently writing some code that needs to have a basic unit testing framework and wanted to install the NUnit framework. This post is about how you can install NUnit, use it and run it with / install it for Visual Studio C# 2008 Express. I will leave the nuts and bolts of unit testing to a future post but this post should get you up and running.
Read the rest of this entry »
Tags: nunit, unit testing, visual studio express C# 2008
Posted in Intermediate, Learn C# | 15 Comments - getting there! »
November 19th, 2008

Multi-tasking / multi-threaded applications have always been a bit of a nightmare to create. Different operating systems and sometimes even different compilers and class libraries tends to have their own implementations. Fortunately the .NET / C# implementation of threading is extremely straightforward and makes it simple to create a multi threaded application. In this article we look at building some very simple threaded applications. We go into how to create them, synchronize them and how we can ensure that things such as shared variables are properly protected.
Read the rest of this entry »
Tags: c-sharp, Learn C#, multi threading, Thread
Posted in Intermediate, Learn C# | Comments Off
November 15th, 2008

You heard might have heard about generics, but how do they work in C# ? And what is that <T> doing in the class definition? This article shows you the benefits of using generics, and how to implement them yourself.
Read the rest of this entry »
Tags: generics, Learn C#
Posted in Intermediate, Learn C# | Comments Off