h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Define Types of Generics

 Generic Classes: 
            The generic represents a data type, during the object‘s life time of the class.
 Generic Methods: 
           The generic represents a data type, during the method execution.

Define Generics


  • Generics are similar to ―templates in C++.
  •  A generic is an identifier, which automatically identifies the data type of a variable.
  •  This is designed to represent a particular data type, during an object life time or a method execution.

 Two types of generics. 

  •  Representing a data type during an object life time.
  •  Representing a data type during the method execution time.


Define rules of Destructor


  • Its name must be defined as class name.
  •  It' name must be started with "~" character.
  •  Access modifier can‘t be specified for this.
  •  No arguments.
  •  No return value.
  •  Destructor overloading is not possible. That means multiple destructors can't be defined inside of a class.


Define Types of Constructors

Implicit constructor:

  •  A constructor, offered by the compiler implicitly is called as "Implicit constructor".
  •  But the compiler automatically offers an implicit constructor, for "constructor-less class" only.

Explicit constructor:

  •  A constructor, defined by the programmer.
  •  It always overrides the implicit constructor.


Define rules of Constructors


  • Its name must be same as "classname".
  •  It must be defined as "public method".
  •  It can be defined with/without arguments.
  •  It can't return any value. So, no return type specification is required.
  • "Constructor overloading" is possible. Writing multiple constructors in the same class is called as "Constructor overloading".

Define “this” Keyword

This is similar to ―this pointer in C++.
 It represents current working object.
 It is used to access the members of current working object.

  • this.field
  • this.property
  • this.method()

Current object: The object, with which object, the method is called.
“this” keyword can‘t be used in the static methods, because static methods doesn‘t have current object.

Define Variable Scopes


  •  A variable scope simply is something, which decides the lifetime of the variable.
  •  The variable scope depends on the place, where the variable is declared in the program.

 For example,
     a variable is declared in if block, is available only within the if block itself.  To have a better idea on this, we discuss about all available scopes in C#.

Define Variables

 Variable declaration:
Syn: datatype variable;
Ex: int x;
Variable declaration along with initialization:
Syn: datatype variable=value;
Ex: int x=10;
Multiple Variable declaration:
Syn: datatype variable1, variable2, variable3,…;
Ex: int x,y,z;
Note:
     When we declare any variable, it should be assigned to a value before its usage.Otherwise, it causes a compile time error.

Define string[] args

   To receive the command like arguments. A command line argument is nothing but an argument, which can be passed from the command window, before the application execution is started.

Define void

It can‘t return any value unlike other methods. So that, it should be defined with void keyword.