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 FileStream

To write / read the content to / write the file, you require file streams.
 A file stream acts as a pointer for the file, which contains the memory address of the file on the disc.
 There are two types of file streams.
1) Reading Streams 2) Writing Streams
Using Namespace for FileStram

  • System.IO.StreamReader (to read the content of the file)
  • System.IO.StreamWriter (to write the content into the file)


Define “Random” class

Library: System.Random

  •  This class is used to generate a random number, at any time.
  •  In future, while performing different programming logics, this random number generation concept may be required.


Define Modifier

new : Methods only : The method hides a base class method with same signature.
static : All members : The member does not depends / instantiates with any of with its class‘s objects. It can be accessed with its class name.
virtual : Methods only :The member can be overridden by a derived class.
abstract :Classes and Methods only : The abstract class can‘t be instantiated. The abstract method is nothing but a virtual method that contains only declaration with no definition. It should be implemented with override keyword in the derived class.
override : Methods only : The member overrides an inherited virtual or abstract member of the base class.
sealed  : Classes  only :The class can‘t be inherited.

Define Types of Inheritance

1) Single Inheritance
  This is the simplest type of inheritance.
  An inheritance relationship, with only one super class and one sub class.
2) Hierarchical Inheritance
 An inheritance relationship, with only one super class and multiple sub classes.
3) Multi-Level Inheritance
  An inheritance relationship, with only one super class and multiple sub classes, and also extended with another sub class from the first sub class.
  In other words, one class acts as super class and sub class simultaneously.
4) Multiple Inheritance
  An inheritance relationship,with only multiple super classes and only one sub class.
  Multiple Implementation Inheritance is not supported by C#, but Multiple Interface Inheritance is supported by C#.
5) Hybrid Inheritance
   An inheritance relationship that contains a combination of any other two types of inheritances.

Define Classification of Inheritance supported by C#:

1) Implementation Inheritance:

  •  This is commonly used inheritance.
  •  Whenever a class is derived from another class, it can be called as ―Implementation Inheritance.
  •  As said above, all of the members of the super class are adopted by sub class.

2) Interface Inheritance:

  •  This type of inheritance is taken from ―Java.
  •  Whenever a class is derived from an interface, it can be called as ―Interface Inheritance.
  •  The interface is similar to the class, but doesn‘t contain the method definitions; it contains the method declarations only. We discuss about the interfaces in-depth later.


Define Indexer in C#.net

This is used to access the object like an array.
Syntax: object[index]
           When you use the above syntax, a field can be accessed.
Syntax for Indexer:
public datatype this[int index]
{
get
{
return arrayname[index];
}
set
{
arrayname[index] = value;
}
}

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.

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.

Define Memory Manager

 The Memory Manager component of CLR, allocates necessary memory for the variables and objects that are to be used by the application.

Define Exception Manager


  •  An exception means Run time error.
  •  This component redirect the processor to execute the catch block or finally block,whenever an exception is occurred at run time.
  •  We can learn how to write these catch and finally blocks in C#.NET and VB.NET languages later.


Define .NET Framework Types

The .NET Framework is available in 3 different types:
 .NET Framework: 
         This is the general version, required to run .NET applications on Windows operating system.
 .NET Mono Framework: 
         This is required to run .NET applications on other operating systems like UNIX, LINUX and Solaris etc.
 .NET Compact Framework:
            This is required to run .NET applications on other devices like PDA (Personal Digital Assistants), Mobile phones and Smart phones.

Define Web Services

Web Services

  •  Web Services are simple and easy to understand.
  •  These can be developed using again ASP.NET.
  •  The web services are used to implement SOA(Service Oriented Architecture) in web applications.
  •  The main purpose of SOA is to implement some interaction between two applications.
  •  Examples:
  •   Online shopping requires credit card authentication, from back web site.

Modules of .NET

VC#.NET (Visual C Sharp.NET) –(Language)

  •  It is highly used .NET programming language, used by most of the .NET programmers.
  •  It borrows some programming features from C and some other programming features from C++. In addition to these, it borrows few of the good features of java language.
  •  It is the object oriented programming language.

VB.NET (Visual Basic.NET) –(Language)

  •  It is the Microsoft‘s recommended language for beginners of windows programming.
  •  But in fact, it is used in very few of the projects in the real-time development world, because most of the programmers usually comes with C and C++ background; hence they feel comfortable with C#.
  •  It borrows some programming features from VB (Visual Basic) language.
  •  It is the object oriented programming language.

ASP.NET (Active Server Pages.NET) – (Web Technology)

  •  It is the Microsoft‘s web technology.
  •  It is used for web sites development.
  •  It offers much attractive and user friendly user interfaces in the server side applications.
  •  It is the new version to another Microsoft‘s technology called ASP (Active Server Pages), which is a famous web technology before introducing ASP.NET.
  •  It requires HTML for web page designing.
  •  It requires a .NET language (like C#, VB.NET, VC++.NET etc.) for server side logic implementation.

ADO.NET (ActiveX Data Objects.NET) – (Database Technology)

  •  It is the Microsoft‘s database technology.
  •  It offers necessary programming libraries to access the local / server databases.
  •  It is the new version to another Microsoft‘s technology called ADO (ActiveX Data Objects), which is a famous database technology, used with VB, VC++ and ASP languages.
  •  It requires a .NET language (like C#, VB.NET, VC++.NET etc.) for logic implementation.


Languages Supported by .NET Framework

Languages from Microsoft : Visual C#.NET,Visual Basic.NET,Visual C++.NET
Languages from other vendors:
VJ#.NET,Python.NET,IronPython.NET,APL.NET,Cobol.NET,Perl.NET,Pascal.NET,Component Pascal.NET,Curriculum.NET,Eiffel.NET,Forth.NET,Fortran.NET,Haskell.NET,Mercury.NET,Mondrian.NET,Oberon.NET,RPG.NET,Scheme.NET,Small Talk.NET,Standard ML.NET

Get Total Quantity from Datagridview in C#.NET

Today , we will see "Get Total from Quantity Column in DataGridView in C#.Net"

Code
private double ADDCoulmnValue(int ColIdx, DataGridView dgv) { for (int idx = 0;idx <dgv.Rows.Count;idx++)
{ tot += Convert.ToDouble(dgv.Rows[idx].Cells[ColIdx].Value);
} }