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.

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.
You put an @ sign in front of the double-quoted string.

String ex = @"This has a carriage return "

The sealed keyword prohibits a class from being inherited.

Displaying 1 of 2Next
1 2
Need Help? Contact Us.

Log in


Forgot password?


New User