BlackWasp
<< Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Next >> |
Adding Descriptive Text to EnumerationsAdding Descriptive Text to Enumerations
Enumerations allow a number of constants to be declared in a group. These constants provide names for numeric values to make code easier to read and maintain. The names are not ideally formatted for display to users but can be enhanced with descriptions.
C# Dynamic TypeC# Dynamic Type
It is common for C# applications to interoperate with other languages and frameworks, including dynamic languages such as Python or Ruby. As the typing systems are fundamentally different, C# 4.0 introduces the dynamic type to simplify integration.
Suppressing C# Compiler WarningsSuppressing C# Compiler Warnings
The C# compiler can generate warnings to indicate possible problems with source code that do not prevent compilation. In some circumstances warnings are expected and may be ignored. In such situations, individual types of warning can be suppressed.
C# Named ParametersC# Named Parameters
With the introduction of C# 4.0, named parameters have been included in the language. Named parameters can be used to enhance the readability of source code and simplify some calls by specifying which parameters the argument values refer to.
C# Optional ParametersC# Optional Parameters
C# 4.0 introduces optional parameters to the language for methods, constructors, indexers and delegates. Optional arguments can be defined within a member's signatures but omitted from calls to that member, in which case a default value is used instead.
#line hidden and #line default#line hidden and #line default
The #line directive allows complete control over the perceived line numbers of a project. This is primarily of use to metaprogramming tools that generate code. The directive includes a variant that allows lines to be hidden from source-level debuggers.
C# Lambda ExpressionsC# Lambda Expressions
C# 3.0 and the .NET framework 3.5 introduced lambda expressions to the language. Lambda expressions permit the creation of anonymous functions with a very concise syntax. They are often used to quickly create delegates for use in LINQ queries.
C# Event AccessorsC# Event Accessors
Events can easily be added to classes to allow objects to indicate when an action occurs. Using standard declarations, multiple subscribers can be added to a single event. To increase the level of control over subscriptions, you can use event accessors.
Using Extension Methods with EnumerationsUsing Extension Methods with Enumerations
Extension methods were introduced in .NET 3.5 to allow classes to be apparently extended without modifying the class' code or using inheritance. Extension methods can also be used to add extra behaviour to enumerations.
C# Nested ClassesC# Nested Classes
When one class is entirely dependent upon another, you may decide to implement it using a nested class. Nested classes are declared within the scope of an existing class and receive special benefits when they access their parent class' members.
<< Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Next >> |
TwitterTwitter RSS Feed RSS