Can abstract class have constructors?

Yes, an abstract class does have a constructor.
It will be called when it subclass is instantiated.


abstract class bank


  public bank()





    class pnb : bank






        static void Main()


            bank b = new pnb();




when the object of  pnb  class is created,
They will be displayed in the output.


Difference between event and delegate?


1) It is a data member of a type(class/structure)

2)It is declared inside a type(class/structure)

3) It is used to generate notifications which are then passed to methods though


1)It is a datatype(reference type) that holds references of methods with
some signatures.also called as function pointer.

2)It may or may not be declared inside a class.

3)It is used as the return type of an event and used in passing messages from event to methods.

Why the Main() method is static?

The Main() method serves as the entry point of the code.It is automatically loaded and initialised by the CLR when the class loader in the CLR loads the class.If it were not static, an extra object of the class has to be created, that would increase the memory overhead.

. The other reason for being static is to prevent its overriding and not allowing it to be accessed through an object reference of derived class.

. Static will also have compile time memory allocation.

Difference between String and string in c#?

1.String is an class(System.String)
2.String is an Reference type(class)

1.string is an alias name of String class that is created by microsoft
2.string is an value type(data type)
3.string is a C# keyword
4.string is a compiler shortcut for System.String class

As per above points when we use string keyword, it reaches the System.String class and then process accordingly, So we can say that both String and string are same.

Page 1 of 41234
eXTReMe Tracker