An object is an instance of a class through which we access the methods of that class. “New” keyword is used to create an object. A class that creates an object in memory will contain the information about the methods, variables and behavior of that class.

A constructor is a member function in a class that has the same name as its class. The constructor is automatically invoked whenever an object class is created. It constructs the values of data members while initializing the class.
Yes, you can say C# is a fully object oriented language. It not only supports the four criteria of OOPs, it also requires that essentially all of your constructs be encapsulated in objects. That is, C# does not let you develop outside of the OOPs methodology in any meaningful way. Where people sometimes say a language is not truly OOPs is where object orientation is optional - such as C++ where you can develop in pure C if you wish.

The built-in libraries are organized within namespaces. Namespaces organize objects in an assembly. An assembly is a reusable, version able and self-describing building block of a CLR application. Assemblies can contain multiple namespaces. Namespaces can contain other namespaces. We can add namespaces in our application used the “using” keyword. Example-

using System;

using System.Collections.Generic;

Destructors’ are used to destruct instances of classes. When we are using destructors in C#, we have to keep in mind the following things:

  1. A class can only have one destructor.
  2. Destructors cannot be inherited or overloaded.
  3. Destructors cannot be called. They are invoked automatically.
  4. A destructor does not take modifiers or have parameters.

Following are the key differences between them: -
1. Structures are value types and classes are reference types. So structures use stack and classes use heap.
2. Structures members can not be declared as protected, but class members can be. You can not do inheritance in structures.
3. Structures do not require constructors while classes require.
4. Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC.

Overriding redefines only the implementation while shadowing redefines the whole element.
Displaying 1 of 3Next
1 2 3
Need Help? Contact Us.

Log in


Forgot password?


New User