are types initializes by default?

  • Thread starter Thread starter Boni
  • Start date Start date
an object must be instanciated to access it. If you do not instanciate it,
it's value will be nothing. Only objects with shared methods, data, or
properties will be accessable with out instanciation in a class like that.
 
Unless oA is assigned a valid reference, it will be Nothing.

Dear all,
 
the question was "is it guaranted?". Is it written somewhere in the .NET
spec, that uninitialized variables are nothing?
 
Siva,

The "New" keyword initializes an object with the value from the type you
tell that it has to be initialized with.

dim a as myOwnClass 'a is an address where in is no reference to an object.
dim a as New MyOwnClass' is initialised accoording the "Sub new" in that
class and/or only with default values/objects from that class.

I hope this helps,

Cor
 
the question was "is it guaranted?". Is it written somewhere in the .NET
spec, that uninitialized variables are nothing?

I'd have to check, but I don't believe that it is guarenteed by the .NET
spec... That is a VB.NET guarentee. For example, in C# Class level
variables are intitialized to their defaults - but locally scoped
variables are not.
 

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