Jump to content
Xtreme .Net Talk

Could someone explain to me the NEW keyword is used for


Recommended Posts

Posted

I'm trying to get a handle on how the NEW keyword is used in VB.NET. could someone shed some light towards this newcomer to VB.NET. Please explain in simplest terms

 

Thanks :D

Posted

It's also used to define constructors. So if you had something like this:

 

Public Class MyNumber
       Private mNum as Long

       Public Sub New(StartingNumber as Long)
           mNum = StartingNumber
       End Sub

End Class

 

You could then define use the class like this:

 

       Dim x As New MyNumber(4)

       Dim y As MyNumber
       y = New MyNumber(4)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...