What is the Signification of the "new " keyword in C#? example
Krishna Rajput Singh
Allocates the memory , create the instance of class
1. create a instance of a class 2. method hiding
to create an instance/ object of the class.
to create a object of a class.
new is used to hide your base class methods through your derive class methods
http://msdn.microsoft.com/en-us/library/ms173153.aspx
i have a one method in the base class like method1() so again i need to create the method1() with same name as in base class, in derived class we use the new keyword to hide the old method in the base class
whenever we use new keyword to create object then automatically memory will be allotted for the data fields and default values are stored into data fields. ex:employee obj1=new employee(); if we cannot use new keyword then memory will not be allotted to the data fields and object will maintenance the null references. employee obj1=employee();
In C# the "new" keyword is used to create an instance of a class.for example: public class Student { } Student objstudent=new Student():