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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top