16
Reply

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

Krishna Rajput Singh

Krishna Rajput Singh

Jul 17, 2014
5.8k
0

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

    Sandesh Patil
    July 24, 2014
    2

    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

    Safayat Zisan
    April 17, 2015
    1

    It is allocating reference to instance

    Dhanik Sahni
    October 09, 2014
    1

    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.

    Alok Tripathi
    March 29, 2017
    0

    New is used to allocate the memory for object reference

    Ashu Elahi
    September 06, 2016
    0

    To allocate reference to instanceThanks

    Amatya Gupta
    April 07, 2016
    0

    used for class object creation and method hiding

    vipin kv
    October 05, 2015
    0

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

    vipin kv
    October 05, 2015
    0

    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

    Rahul Prajapat
    June 01, 2015
    0

    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

    Maruthi Pallamalli
    February 11, 2015
    0

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

    Munesh Sharma
    October 09, 2014
    0

    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. :)

    Manoj Rawat
    August 09, 2014
    0

    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.

    jayasri
    August 01, 2014
    0

    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

    Mohit Kumar
    July 28, 2014
    0