 | Obtaining a Stack Trace Call stacks are used to control the flow of programs as methods and properties are executed and terminated. When adding diagnostic code, such as logging, to software it can be useful to examine the call stack for a thread or exception using a stack trace. |
 | Setting the Title for Console Applications The title bar for a console application that is executed from a command prompt generally shows a default title, rather than the name of the console application. This title can be modified by setting a static property of the Console class. |
 | Lazy Initialisation with Lazy<T> When working with resource intensive objects or types that are slow to instantiate, especially where those objects may not be required, it can be useful to only create the objects when first needed. This technique is known as lazy initialisation. |
 | Obtaining File Version Numbers .NET assemblies can be given three distinct version numbers, each serving a different purpose. It can be useful to obtain these version numbers at run-time. This is made possible with reflection and the use of the FileVersionInfo class. |
 | Console Application Cursor Position Many console applications are simple programs that output a series of lines of text, scrolling the console window when the available space is filled. However, by manipulating the cursor position, more complex output is made possible. |
 | Using Enum.HasFlag Prior to version 3.5 of the .NET framework, extracting individual flags from an enumeration required the use of logical bitwise operators. In .NET 3.5, the need for logical operations is removed with the introduction of the Enum.HasFlag method. |
 | Identifying the Default Comparers for a Type When creating methods that perform comparison or sort operations, it is usual to allow callers to use a default comparer, a standard .NET comparers or a custom class. For generic methods, it is essential to be able to obtain a default comparer for a type. |
 | Implementing IComparer<T> The generic IComparer<T> interface was introduced with the .NET framework version 2.0. It is used to compare two values to determine which is the larger. The interface is used in many standard .NET methods, particularly those that sort information. |
 | Implementing IEqualityComparer<T> IEqualityComparer<T> is a generic interface defined in the .NET framework version 2.0 and used in many standard classes, including several LINQ operators. The interface can be implemented to allow customised comparison of values and objects. |
 | Obtaining the Week Number for a Date Accounting software, time-keeping utilities and calendar applications often present dates using week numbers that commence at the beginning of the year. Using the .NET framework's Calendar class a week number can be calculated using a number of rules. |