16
Reply

What is the Signification of the "new " keyword in C#? example

    used to create instance of a class or to shadow a method declared in base class.

    new is used to allocate memory in hard drive. example: int() a = new int(10) here, new keyword is allocating 10 integer numbers in a array

    It is allocating reference to instance

    In C# the "new" keyword is used to create an instance of a class.for example: public class Student { } Student objstudent=new Student():

    "new" keyword is used to create a object in a heap. Basically any object have two parts first is "reference variable" and other is "object" itself , reference variable is resides in stack and object is in heap. So new in used to create the object in heap and the reference variable is used to point the object in heap.Ex : Employee E1(ref var)= new Employee();(object created in heap)and these objects are clean by the garbage collector when it not used for long times.

    New is used to allocate the memory for object reference

    To allocate reference to instanceThanks

    used for class object creation and method hiding

    new keyword can be used to create class instance or can be used in method hiding

    new keyword is use to get an reference of a class, structure . when we use a new operator then a memory block of size of object type(class/reference) is allocated in memory and address of this memory block is assigned to object

    new keyword is use to get an reference of a class, structure . when we use a new operator then a memory block of size of object type(class/reference) is allocated in memory and address of this memory block is assigned to object

    New is a keyword. To get reference or addressing of the objects. New keyword will work for Variables(int,float ,..... example : int i=new int();) New keyword will work for class ( classA a =new classA(); ) New keyword also work as modifier publc classA { public void AB(){ } } public classB:A { new public void AB() { } } More over it will use to assign memory dynamically

    http://msdn.microsoft.com/en-us/library/ms173153.aspx

    Example- foo obj = new foo(); Left Part initializes/declares the object and right part ( new foo() ) allocates memory to newly created Object.Please Correct me if i am wrong. :)

    In C#, a method in a derived class can have the same name as a method in the base class. You can specify how the methods interact by using the new and override keywords. The override modifier extends the base class method, and the new modifier hides it. The difference is illustrated in the examples in this topic.

    used for creating the new object for the class and hiding the member of parent class in child if it is intended.For similar kind of interview question check this also c# interview questions