How do I know when to use 'New' for variables?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:

How do I know when to use 'New' when declaring a variable? How do I know
when an instance can be created?

Ex:
Dim x As New System.Random
-versus-
Dim mailMessage As System.Web.Mail.SmtpMail (this produces an error!)

VS.Net 2003

Thanks.
 
How do I know when to use 'New' when declaring a variable? How do I know
when an instance can be created?

Look in the documentation if the class has any public constructors.
SmtpMail doesn't have any public constructors, but you don't need it
since all its methods are Shared.


Mattias
 
Back
Top