C# Overloaded Methods with Inherited Arguments

No Comments »

This article discusses one of those programming topics that may be confusing at first but seems obvious once you know it.

As you know, C# enables you to overload the same method in a class with different arguments.  But it’s also possible to overload a method with arguments that inherit from one another.

Read the rest of this entry »

Find the Root of a C# Hierarchy

2 Comments »

Many objects in .NET are stored in a hierarchy.  For example: controls, files and folders, and anything you would normally display in a tree view.  There are many different algorithms for finding the root of a hierarchy.  Here is one of them:

Read the rest of this entry »

Interview with C# Leader Anders Hejlsberg

1 Comment »

Computerworld has published an in-depth interview with Microsoft’s leader of C# development, Anders Hejlsberg.  A prominent Danish software engineer, Hejlsberg also wrote Turbo Pascal and was lead architect of the team that developed Delphi.  Hejlsberg shared with Computerworld his thoughts on the development of C#, future programming trends, and his experiences putting out fires.  Here is a brief excerpt:

Read the rest of this entry »

Determine if Your C# Application is 64-bit

6 Comments »

It’s easy to determine if your C# application is 64-bit.  Just check the Size property of IntPtr.  If it’s 8, then your application is 64-bit.  If it’s 4, then your application is 32-bit.

Here is a simple C# console program to demonstrate this:

Read the rest of this entry »

C# Switch Case Order Doesn’t Matter

3 Comments »

The order of C# switch case statements in your code has no effect on performance.

Read the rest of this entry »

Sort C# Array in Descending/Reverse Order

1 Comment »

How do you sort a C# array in descending or reverse order?  A simple way is to sort the array in ascending order, then reverse it:

Read the rest of this entry »

Check Valid File Path in C#

1 Comment »

It’s not a trivial exercise to validate a file path on a Windows PC.  There are a few special cases depending on the file system and operating subsystem (source):

Read the rest of this entry »

Display an RTF File that’s a C# Embedded Resource

No Comments »

It’s easy to display an RTF file — that was embedded as a resource in a C# program — in a Windows Form RichTextControl.

Read the rest of this entry »

Add Shaded Rows to ListView Details View

2 Comments »

Sometimes it can be challenging to read the Details view in a ListView, especially if the rows are long.  This article shows how to add shading to every second row to make a ListView easier to read.

ListView Shaded Rows

Read the rest of this entry »

Extract Application’s Own Icon in C#

No Comments »

It’s easy to extract an application’s own icon in C#:

form.Icon = Icon.ExtractAssociatedIcon( Application.ExecutablePath );

The ExtractAssociatedIcon static method on the Icon class (in System.Drawing) extracts the associated icon from any file.  By supplying the Application.ExecutablePath (in System.Windows.Forms), you extract the application’s own icon.

keep looking »