Nov 29
Following are some simple but useful FREE tools for software developers. Each tool is freely distributable and includes the original C# source code so you can modify the tool to your needs. These tools are not supported. Enjoy!
Color Gadget
Select a .NET KnownColor or other color, copy RGB and hex values to the clipboard.
Free Download
Guid Generator
Generate a new globally-unique ID and copy it to the clipboard.
Free Download
Hex Converter
Quickly convert between hex and decimal numbers.
Free Download
Shortcut Replace
Search/replace the path and working directory in a collection of shortcut (.lnk) files.
Free Download
Visual Studio Toolbox Installer
Console program that installs/removes tabs and custom controls and components in the Visual Studio .NET Toolbox.
Free Download
Window Watcher
Shows the form and client bounds of the active window.
Free Download
Nov 28
C# 2.0 introduced the ?? or null coalescing operator. The ?? operator has two operands and can be used in an expression as follows:
x = y ?? z;
Read the rest of this entry »
Nov 26
Microsoft has released Visual Studio 2008 and .NET Framework v3.5. These upgrades enable .NET software developers to rapidly create more secure, manageable, and reliable applications and take advantage of new features found in Windows Vista and Microsoft Office 2007.
Read the rest of this entry »
Nov 19
When a program calls a synchronous function, the program halts and waits for the function to finish executing. When a program calls an asynchronous function, the program does not wait and continues to execute while the asynchronous function executes in the background.
By default, C# methods are synchronous. External functions that can take a long time to execute–such as interprocess communications (IPC) and database queries–are typically asynchronous. However, there may be instances where you need to make a synchronous function asynchronous and vice-versa.
Read the rest of this entry »
Nov 05
A sort is stable if the original order of equal elements is preserved. An unstable sort does not guarantee that equal elements will appear in their original order after sorting.
The Sort methods used by the .NET collections are unstable. These sort methods, which include System.Array.Sort and System.Collections.Generic.List<T>.Sort, use the QuickSort algorithm, which is relatively fast but in this case, unstable. However, there may be instances where you require a stable sort, so a custom solution is required.
Read the rest of this entry »
Sep 28
No programming language is perfect. In spite of the many strengths of C#, there are still a few gaping holes, including generics variance and property delegates.
A delegate is a reference to a method. Unfortunately, C# currently does not support property delegates, in other words, a reference to a property. But there are a few workarounds, one of which involves anonymous methods.
An anonymous method is a new feature in C# 2.0 that enables you to define an anonymous (nameless) method called by a delegate. Anonymous methods are perfect when there is no need for multiple targets, and the code is relatively short and simple. They also come in handy when you need a delegate to a property.
Read the rest of this entry »
Sep 20
Generics in .NET 2.0 provides the ability to create strongly-typed collections in C#. Unfortunately, C# currently does not support generics variance, which would allow inheritance of generic types.
For example, consider a list of strings and a list of objects:
List<string> strings = new List<string>();
strings.Add( "hello" );
strings.Add( "goodbye" );
List<object> objects = new List<object>();
objects.AddRange( strings );
The final line in the code above generates a compiler error. But why? Since the ‘string’ class derives from the ‘object’ class, one would expect List<string> to also implicitly derive from List<object>. This capability is called generics variance, but C# currently does not support it.
Fortunately, you can brute force your way to a solution by creating a generic ConvertIEnumerable method:
Read the rest of this entry »
Aug 08
The SecureString class is new in the System.Security namespace with the .NET v2.0 upgrade. SecureString keeps sensitive data encrypted in memory so that it cannot be easily stolen. SecureString plugs a specific security hole but does not guard against all threats while securing information in applications.
Read the rest of this entry »
Jul 26
The .NET 2.0 upgrade included many minor improvements that are easily overlooked. One such improvement is Padding, a handy structure in the System.Windows.Forms namespace that you may find useful for representing offsets, margins or padding in the user interface.
Read the rest of this entry »
Jul 25
Delegates can be tricky to understand. Think of a delegate as a reference to a method (pointer to a function).
Read the rest of this entry »