Thursday, October 4, 2018

Published 6:03 AM by with 0 comment

Sealed Classes

Sealed Class In C#:

What is Sealed Class?

In some situation we don't want to inherited  a base class, So for that purpose we declared it a sealed class.

    public sealed class baseclass 
{


 } 
Read More
      edit
Published 5:25 AM by with 0 comment

Polymorphism In C#

Polymorphism:

An object contains many forms/types.

Compile time Polymorphism(its also Early binding, overloading, static polymorphism)
Compile time Polymorphism is also known as method overloading. Method overloading means having two or more methods with the same name but with different signatures.
Run time Polymorphism(its also Late binding, overriding, dynamic polymorphism)
Run time Polymorphism is also known as method overriding. Method overriding means having two or more methods with the same name and same signature, but with a different implementation.

Overloading: Two or more method have same name but different signatures(parameters)
Overriding: Two or more method have same name and signatures(parameters) but implimentations is different.
Read More
      edit
Published 2:41 AM by with 0 comment

What is IndexOutOfRangeException?


What is System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection OR IndexOutOfRangeException?

Solution:

1.What Is meant of ArgumentOutOfRangeException OR IndexOutOfRangeException?



In C#,When you try to access a collection of item in an array through using an invalid index  it say IndexOutOfRangeException. 

When an index is invalid?

An index of an array is invalid when its lower that the collection's lower bound or greater than or equal to the number of items the collection contains.

when it throw an IndexOutOfRangeException?

Given an array is declares as:

            
var idList = new int[4] { 8, 10, 11, 12 };

The amount in the square bracket is index/es.it range is 4 means you access this array from 0 to 3.and  8,10,11,12 are the items it contain, when you try to access this value outside this range it will through exception IndexOutOfRangeException. So remember this when you try to access any array.Range/Length of arrays:
In C#, arrays range is start from 0 index and its end on range-1(where the range is total number of items an array contains ).
so this code will not work :

Itemlist = idList[10]
because indexes range is 4 and we call 10.





Read More
      edit