C# Indexers

What is an Indexer? Most C# programmers first use an indexer when working with an array. An array is used to store a number of similar, related variables under the same name, with each variable accessed using an index number provided in square brackets. For example:

Often it is useful to incorporate the square bracket notation for new classes. This may be because the class is used to store related information in a similar manner to an array, or simply because the index number can be useful in a calculation or lookup. Adding an indexer to a class provides … Click here to continue…..

C# Basic Operator Overloading

Operator Overloading So far in this tutorial we have created classes to represent real-world objects complete with their appropriate methods and properties. These objects have not required the implementation of arithmetic operators as this type of functionality was not appropriate. In this article, we will create a class that does support arithmetic operations through the use of operator overloading. Operator overloading is simply the process of adding operator functionality to a class. This allows you to define exactly how the operator behaves when used with your class and other data types. This can be standard uses such as the ability … Click here to continue…..

How to write XML file by using dotnet code?

C# Static Behaviour

Why Use Static Behavior? To date, the methods, properties and constructors that have been described in this tutorial have all related to instantiated objects of classes. In each case, these members have defined how the individual objects behave and how they maintain and manipulate their own state. Sometimes you will want to create behavior that is not linked to any individual object, instead being available to all instances and to objects of other classes. This is where static members become useful. A good example of a static method is the Main method, which is used in every executable program. When … Click here to continue…..

C# Constructor Overloading

Constructor Overloading In this article we will combine two techniques to allow a number of constructors to be defined for a single class. This gives the class the flexibility to construct objects in a variety of ways according to the manner in which they are to be used. Creating Overloaded Constructors Creating an overloaded constructor is as simple as adding overloaded methods. The additional constructors are simply added to the code. Each constructor must have a unique signature, ie. the parameter types must differ from all other constructors. To demonstrate the use of overloaded constructors we will create a new … Click here to continue…..