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 | 9 | 10 | 11 | 12 | Next >> |
Re-throwing Exceptions and the Call StackRe-throwing Exceptions and the Call Stack
When an exception is caught, it may need to be re-thrown to be handled by methods that appear deeper in the call stack. The way in which an exception object is re-thrown can lead to changes in the information that it holds.
Forced Override of Virtual MethodsForced Override of Virtual Methods
Some scenarios require that virtual methods must be overridden in subclasses of a given type, an example being a requirement to override GetHashCode and Equals in data objects. This example describes how to enforce such overriding.
C# Variable Naming and the @ SymbolC# Variable Naming and the @ Symbol
C# allows very flexible naming of variables and other symbols. This includes the use of alphanumeric characters, a mixture of upper and lower case letters and the underscore symbol. It is even possible to use a variable name that is a reserved word.
Console Applications and %ERRORLEVEL%Console Applications and %ERRORLEVEL%
When developing console applications that may be launched from batch files it can be helpful to return an integer to indicate the final status of the program. This value can be interrogated in the batch file using the %ERRORLEVEL% environment variable.
C# Optional Parameters in Library CodeC# Optional Parameters in Library Code
C# optional parameters provide a handy way to create methods that can be called with a varying number of arguments but without the need to create overloaded versions. However, the way that they are used in referenced libraries can cause problems.
Looping Through an Entire Integer RangeLooping Through an Entire Integer Range
As most for loops rely on a predicate that is based upon the loop control variable, iterating through an entire integer range is not as simple as it may first seem. An easy way to overcome the problems caused is to use a while loop instead.
C# ClosuresC# Closures
Closures are usually associated with functional programming languages, where they link a function to its referencing environment, permitting access to variables outside of the function's scope. With the use of delegates, closures are available in C#.
Creating Type Aliases in C#Creating Type Aliases in C#
The using directive of the C# programming language is often used to create namespace aliases, allowing types with matching names that appear in separate namespaces to be easily accessed. A lesser known use of the directive is to create aliases for types.
C# Static Field Initialisation OrderC# Static Field Initialisation Order
Static fields can be used to hold information that is made available by, or used within, a class without requiring that an instance of that type is created. When initialising static fields, care must be taken that values are applied in the correct order.
C# Sizeof KeywordC# Sizeof Keyword
In some situations it is necessary to know the size of a value type, such as a built-in numeric data type or a custom structure. The number in bytes can be looked up or calculated, or the sizeof keyword can be used to automatically obtain the size.
<< Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Next >> |