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 Auto Implemented Properties

This is introduced in C#.NET 3.0.

  •  To simplify the syntax of property declaration that contains no extra logic in ―set accessor and ―get accessor, this concept is introduced.
  •  According to this, no code for ―set and ―get accessors needed to write.
  •  No extra variable is needed to be declared.
  •  Syn: accessmodifier datatype propertyname { get; set; }
  •  Ex: public string Name { get; set; }


Define Write Property in C#.net

Simply implement ―set accessor only, don‘t implement ―get accessor.
 Syn:
private datatype variablename;
accessmodifier datatype propertyname
{
set
{
variablename = value;
}
}

Define Read only Property in C#.net

Simply implement 
         get accessor only, don‘t implement ―set accessor.
 Syn:
private datatype variablename;
accessmodifier datatype propertyname
{
get
{
return (variablename);
}
}

Define Set and Get Accessor in Property

The “Set” Accessor:
1. This gets called automatically, whenever a value is assigned to the property in the client code. Ex: obj.property = value;
2. The value that is assigned in the client code is available as ―implicit parameter,named value in this set accessor.
3. This accessor can‘t return any value.
The “Get” Accessor:
1. This gets called automatically, whenever the property value is requested in the client code. Ex: obj.property
2. No implicit parameters are available.
3. This accessor should return the value of the property.

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.