New Keyword - can precede the derived class method name...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
What is the purpose of the New keyword? Explain what happens when this keyword is used in an application? It creates a new instance of an object or class. It is also used to create a new array. Internally it allocates the memory to an object. The keyword “new” is used to create the object for the classes using that object all the methods and properties are invoked. In Vb.Net this keyword extensively, it used to assign an object the memory on heap, and thus physically implements the class for that particular object. New is not used just to create objects of a class. It is also used for shadowing a method in .NET, which means if Base class and Derived class have methods with same name and signature, you
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: can precede the derived class method name with "new" keyword which makes the method a new one altogether. This is used in retaining old implementation of a method and you also want to introduce new implementation for same method in your assembly. The new keyword is basically used in reference types to create an object and allocate memory to it, and it can also be used in value types to invoke the default constructor. To create an instance of a class, use the New keyword. Example for New keyword Public Class ShowMe Sub ShowFrm() Dim frmNew As Form1 frmNew = New Form1 frmNew.Show() frmNew.WindowState = FormWindowState.Minimized End Sub End Class...
View Full Document

This note was uploaded on 11/25/2010 for the course CS cs 201 taught by Professor Unknown during the Spring '10 term at Apex College.

Ask a homework question - tutors are online