c#

Overloading

Overloading, can be achieved in a class by differentiating in:

  1. Number of arguments
  2. Order of arguments
  3. Type of arguments

Cannot create instance of the abstract or interface

Though Abstract classes can contain constructors and the compiler wont raise exception, but when creating object of abstract class the code wont compile, will state error as “Cannot create as instance of the abstract class or interface”

Error Code:

namespace n1
{
abstract class c1
{
public c1()
{
Console.WriteLine("c1");
}
}


class c2: c1
{
public c2()
{
Console.WriteLine("c2");
}
static void Main()
{
c2 c = new c1();
System.Console.ReadLine();
}
}
}