Polymorphism , the third pillar of object-oriented programming, is closely related to inheritance. The prefix poly means many; morph means form. Thus, polymorphism refers to the ability of a single type or class to take many forms. There are times that you will know you have a collection of a general type, for example a collection of Controls, but you do not know (or care) what the specific subtype each of your controls is (one may be a button, another a list box, etc.). The important thing is that you know they all inherit shared abilities (e.g., the draw method) … Click here to continue…..


The second pillar, specialization, is implemented in C# by declaring that a new class derives from an existing class. When you do so, the specialized class inherits the characteristics of the more general class. The specialized class is called a derived class, while the more general class is known as a base class. The specialization relationship is referred to as the is-a relationship. A dog is a mammal, a car is a vehicle. (Dog would be derived from the base class Mammal and Car from the base class Vehicle.) Specialization allows you to create a family of objects. In Windows … Click here to continue…..

How do you declare a static variable and what is its lifetime? Give an example.

static int Myint–The life time is during the entire application. OR The static modifier is used to declare a static member, which belongs to the type itself rather than to a specific object. The static modifier can be used with fields, methods, properties, operators, events and constructors, but cannot be used with indexers, destructors, or types. In C#, the static keyword indicates a class variable. In VB, the equivalent keyword is Shared. Its scoped to the class in which it occurs. Example Static int var //in c#.net static void Time( ) //in c#.net

Features of C#

Microsoft describes C# as a simple, modern, object-oriented, and type-safe programming language derived from C and C++. Most independent observers would probably change that to derived from C, C++, and Java. Such descriptions are technically accurate but do little to convey the beauty or elegance of the language. Syntactically, C# is very similar to both C++ and Java, to such an extent that many keywords are the same, and C# also shares the same block structure with braces ({}) to mark blocks of code and semicolons to separate statements. The first impression of a piece of C# code is that … Click here to continue…..


How many types of classes in .Net?

The class is one of the two basic encapsulation constructs in C# (the other being the struct). Every executable statement must be placed inside a class or struct. Classes define reference types that are the basic building blocks of C# programs, and they are the architectural blueprint for the “objects” in OOP. Types of classes :- Abstract: An instance of the class cannot be created. Usually this means the class is intended to serve as a base class. Abstract methods must be overridden in a derived class. If any method of a class is abstract, the entire class must be … Click here to continue…..