February 3rd, 2009
If you are interested in turning a C# string into an integer, float, double or any other kind look no further. In todays post we make use of the convert and parse methods to convert strings into numbers. Read the rest of this entry »
Tags: converting, float, integer, string
Posted in Beginner, Learn C# | No Comments, yet!
January 7th, 2009

Occasionally you need to time the performance of a C# function to see if its as fast, or as slow, as you think it is. You could of course run your code through a profiler. But in situations that that would be overkill there exists a quick solution. Originally I looked at the standard DateTime class, but NET 2.0 introduced theĀ Stopwatch class which is much more suitable. In this post I look at how you can measure your functions performance down to the last fraction of a millisecond.
Read the rest of this entry »
Tags: datetime, function execution, Learn C#, stopwatch, timing
Posted in Beginner, Learn C# | 1 Comment already!»
January 5th, 2009

In an earlier post I looked at how I could add my own icon to the Gnome Notification area from my Mono C# applications. The next thing I wanted to do was to show a notification in the taskbar to the user when something truly important happens. If you are running Ubuntu Intrepid (8.10) then its easy to create them from Mono. As I found out, Hoary (8.04) doesn’t include the required libraries.
Read the rest of this entry »
Posted in Beginner, GTK, Learn C# | 1 Comment already!»
January 2nd, 2009

Cool (Linux) applications have their own icon in the notification area. To add my own icon in the Gnome notification area using Mono only took a few lines of code. In the post below I show how you can add your icon and associate a tooltip and right click menu to it.
Read the rest of this entry »
Tags: GTK, Learn C#, mono, StatusIcon, Tooltip
Posted in Beginner, GTK, Learn C# | 3 Comments - getting there! »
January 1st, 2009
Sorting a basic generic list in C# is trivial as long as you store basic elements such as strings or integers for which default comparison classes have been defined. In this post we will look into how we can reverse the string sort by implementing your own ICompare comparer, and how you can build your own comparison routines to compare other types. In the example we sort a list (List<>) of people by both their name and their age.
Read the rest of this entry »
Tags: generic, ICompare, Learn C#, list, quicksort, sorting
Posted in Beginner, Learn C# | 2 Comments - getting there! »
December 30th, 2008
In a previous post I looked at how to build a very simple linked list in C#.. That class had many problems, including that it exposed quite a bit of its inner workings to the outside world. In this post I will introduce a C# generic LinkedList class that implements the Java LinkedList specification and behaves accordingly. I used this opportunity to explore how to apply unit testing with NUnit to effectively test the development process.
Read the rest of this entry »
Tags: linked list, nunit, unit testing
Posted in Algorithms, Beginner, Learn C# | No Comments, yet!
December 30th, 2008
Unit testing with NUnit is deeply integrated into Mono. The Mono code itself uses NUnit extensively to test its own functionality. In this post we look at how you can enable unit testing for your own code under MonoDevelop. In an earlier post I looked at how to install NUnit for Visual Studio 2008 Express, in this post we do the same for MonoDevelop.
Read the rest of this entry »
Tags: monodevelop, nunit, unit testing
Posted in Beginner, Learn C# | 6 Comments - getting there! »
December 29th, 2008
There is re-markedly little honor in building your own linked list class in C#. The standard libraries provide a solid implementation in the LinkedList generic class. The point of languages such as C# and Java is of course that code re-use should be the top priority, so why re-invent one of the most elementary wheels of computer science? In this post I will look at why you could use a linked list, and how they work.
Read the rest of this entry »
Posted in Algorithms, Beginner, Learn C# | 1 Comment already!»
December 12th, 2008
This post looks at how to implement a binary tree using generics in C#. A binary tree is a data structure in which each node has at most two children. They are a good way to store unsorted data, as the data becomes sorted as you insert it into the tree.
Another benefit of storing information in a tree structure is the opportunity for faster search times. In an array (or list) you need to traverse the whole array to discover if it contains a particular value. A well-balanced binary tree can drastically reduce the number of look-ups required.
Read the rest of this entry »
Tags: binary tree, generics, Learn C#
Posted in Algorithms, Beginner, Learn C# | 1 Comment already!»
December 10th, 2008
It is often necessary to convert binary data to and from strings. One common way of encoding such information is through Base-64 encoding. The following post shows you how to convert a byte array to a Base64 string , and back again.
Read the rest of this entry »
Tags: base64, convert
Posted in Beginner, Learn C# | 2 Comments - getting there! »