C# Events

What is an Event? Each of these is similar because it allows a direct command to be given to a class or object within the flow of a program. This is similar to the early programming languages, which simply processed a sequence of commands and loops until complete. The sequential or procedural method of programming is limited to this type of processing. However, C#’s object-oriented approach is also event-driven. This means that as activities occur, a class may raise events to indicate the action that happened and to pass related information to other classes that have subscribed to the event. … Click here to continue…..

C# Method Overloading

Method Overloading One of the key features of object-oriented programming is polymorphism. Polymorphism permits objects to behave in different ways according to the manner in which they are used. One part of polymorphism is the ability for a method to behave differently according to the types and number of parameters that are passed to it. This is achieved through method overloading. Method overloading allows the programmer to define many methods with the same name but with a different set of parameters. Each combination of parameter types is known as a signature of the method. When a call is made to … Click here to continue…..

C# 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 signature but omitted from calls to that member, in which case default values are used instead. Often your source code will include several overloaded versions of one or more members. Sometimes the overloads will be created so that different types can be passed to, and returned from, a method. In these cases, the signatures of the overloads may differ significantly. However, it is common to create a number of overloaded versions of a member where each version simply … Click here to continue…..

C# Anonymous Types

A new feature of C# 3.0 is the ability to create anonymous types. These interesting classes are defined for temporary use within class members. They allow the convenient encapsulation of read-only properties without the need to code a complete class. What is an Anonymous Type? Usually well-defined classes encapsulate the behavior and state of a type of object, hiding the implementation details from the class’ consumers. However, sometimes a lightweight class will be defined that contains only properties and that is for use in only a small section of code. Creating a new definition for such a class can be … Click here to continue…..