By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,673 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,673 IT Pros & Developers. It's quick & easy.

are types initializes by default?

P: n/a
Dear all,
----
class myA
...
end class
dim oA as myA
---
is it guaratned by the .NET spec that oA is nothing?
Thanks,
Boni
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies

P: n/a
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.
Nov 21 '05 #2

P: n/a
"Boni" <oilia@nospam> schrieb
Dear all,
----
class myA
..
end class
dim oA as myA
---
is it guaratned by the .NET spec that oA is nothing?

As long as it is not anything, it is nothing.
Armin
Nov 21 '05 #3

P: n/a
Unless oA is assigned a valid reference, it will be Nothing.

"Boni" <oilia@nospam> wrote in message
news:OP**************@TK2MSFTNGP10.phx.gbl...
Dear all,
----
class myA
...
end class
dim oA as myA
---
is it guaratned by the .NET spec that oA is nothing?
Thanks,
Boni

Nov 21 '05 #4

P: n/a
the question was "is it guaranted?". Is it written somewhere in the .NET
spec, that uninitialized variables are nothing?

"Siva M" <sh******@online.excite.com> schrieb im Newsbeitrag
news:uP*************@TK2MSFTNGP15.phx.gbl...
Unless oA is assigned a valid reference, it will be Nothing.

"Boni" <oilia@nospam> wrote in message
news:OP**************@TK2MSFTNGP10.phx.gbl...
Dear all,
----
class myA
..
end class
dim oA as myA
---
is it guaratned by the .NET spec that oA is nothing?
Thanks,
Boni

Nov 21 '05 #5

P: n/a
Armin,


As long as it is not anything, it is nothing.

I don't know why however I find "Something" nicer.

:-)

Cor
Nov 21 '05 #6

P: n/a
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
Nov 21 '05 #7

P: n/a
On 2005-07-23, Boni <oilia@nospam> wrote:
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.

--
Tom Shelton [MVP]
Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.