• Tag Archives
  • C
  • 2 Posts

How to sort collections of custom types in C#

I’ve recently created a program which sorts collections of custom types quite extensively and i thought i’d share the standard method of doing this. When i first started designing my program, i honestly thought it would be quite a pain sorting these collections but i was pleasantly surprised, as usual by the .NET framework, that there are built in shortcuts.

Enumerations in C, the good, the bad and the ugly

I’ve started to brush up on my C programming and learn the language properly. So, after reading through a chapter in the famous¬†White Bible, i’ve come to the conclusion that C enumerations are pretty bad.

C enumerations have a nice syntax and they are really handy when defining a range of constants with unique int values, but, and here’s the big issue, they are not type checked against a particular named enum, they are only checked that they are an int! Take this code: