BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

<< Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Next >> |
Obtaining a Stack TraceObtaining 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 ApplicationsSetting 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&lt;T&gt;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 NumbersObtaining 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 PositionConsole 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.HasFlagUsing 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 TypeIdentifying 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&lt;T&gt;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&lt;T&gt;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 DateObtaining 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.
<< Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Next >> |