Array-sorting using generics and anonymous methods

Alternative 1 (type safe sorting using generics):

private int ComparePass(Pass x, Pass y)
{
    if (x.Starttid < y.Starttid) return -1;
    if (x.Starttid > y.Starttid) return 1;
    return 0;
}
:
:
    Pass[] results = ...;
    Array.Sort<Pass>(results, ComparePass);
:

Alternative 2 (type safe sorting using generics and an anonymous method):

Pass[] results = ...;
Array.Sort<Pass>(results,
    delegate(Pass x, Pass y)
    {
        if (x.Starttid < y.Starttid) return -1;
        if (x.Starttid > y.Starttid) return 1;
        return 0;
    });

Alternative 3 (type safe sorting using generics and an anonymous method using a default comparer):

Pass[] results = ...;
Array.Sort<Pass>(results, 
    delegate(Pass x, Pass y)
    {
        return Comparer.Default.Compare(x.Starttid, y.Starttid);
    });

Draw icon with the alpha channel enabled

Here’s how to draw an icon in a control utilizing the icon’s built-in alpha channel.

private void cmdEmail_Paint(object sender, 
  System.Windows.Forms.PaintEventArgs e)
{
  System.Drawing.Icon icon;
  icon = new Icon(
    GetType().Module.Assembly.GetManifestResourceStream(
      "ActiveSolution.Lernia.SFI.WinClient.Images.mail.ico"),
    16, 16); 
  e.Graphics.DrawIcon(icon,0,0);
}

The name of the icon resource is easily found using ildasm. Double-click on the “M A N I F E S T” node and look for the icon in the window that opens.