Home About

 February 3rd, 2009

Converting C# strings to other types - 0

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 »

 January 7th, 2009

Timing C# function performance with the Stopwatch class - 1

Timing C# function execution time with a stopwatch
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 »

 January 5th, 2009

Showing Gnome/Ubuntu LibNotify Notifications from Mono and C# - 1

Gnome / Ubuntu Notification displayed using Mono / C#

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 »

 January 2nd, 2009

Creating a GTK notification area icon using Mono and C# - 3

Adding a Gnome tooltip to your application with C# and Mono

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 »

 January 1st, 2009

Sorting Generic Lists in C# - 2

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 »

 December 30th, 2008

Using Linked lists in C# – Part II - 0

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 »

 December 30th, 2008

Using NUnit with MonoDevelop - 6

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 »

 December 29th, 2008

Using linked lists in C# – Part I - 1

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 »

 December 12th, 2008

Implementing a Generic Binary Tree in C# - 1

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 »

 December 10th, 2008

Encoding and Decoding Binary data using Base64 with C# - 2

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 »


Recent Comments
  • Ales: Hi, Thanks for the code… I must say I did not experience any errors decrypting any of my messages. I even...
  • JC: Thanks very useful and well explained
  • Thomas: This is a public static class written in the C# language that does not save state. You can call into the...
  • Simon: Thank you very much for this post! It helped me essentially to overcome obstacels to work with mono!
  • Graham: This is a good research for keyboard shortcuts! Some shortcuts are also compatible for Windows OS. I have...