473,327 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

are types initializes by default?

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
7 852
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
"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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Edward Diener | last post by:
Is there a way to override the default processing of the assignment operator for one's own __value types ? I realize I can program my own Assign method, and provide that for end-users of my class,...
8
by: Marcin Kalicinski | last post by:
Hi, void f() { int i1; // i1 now holds undefined value int i2 = int(); // i2 now holds 0 } Is the above true?
9
by: Pierre Senellart | last post by:
The C++ standard states (26.3.2.1), about std::valarray constructors: > explicit valarray(size_t); > > The array created by this constructor has a length equal to the value of > the argument....
2
by: Champika Nirosh | last post by:
Hi All, I have the string value of the System types.. now I need to get the default value for that system type.. I have string s = "int"; not I need string sd = "0"; sd is the default...
5
by: Anders Borum | last post by:
Hello! Whilst refactoring an application, I was looking at optimizing a ModelFactory with generics. Unfortunately, the business objects created by the ModelFactory doesn't provide public...
6
by: Steven Livingstone | last post by:
Bit of advice here folks. I am creating a default constructor that just initializes a new instance of my object and a secon constructor that takes an ID and loads an object with data from the...
12
by: Edward Diener | last post by:
Given value class X { public: // Not allowed: X():i(100000),s(10000) { } // Allowed void InitializeDefaults() { i = 100000; s = 10000; } private: int i;
4
by: Dmytro Bablinyuk | last post by:
I came across several possible ways of allocating memory for objects, for example: 1. malloc(sizeof(T)*3)/free - raw memory 2. new T/delete - buffer would be initialized to...
55
by: tonytech08 | last post by:
How valuable is it that class objects behave like built-in types? I appears that the whole "constructor doesn't return a value because they are called by the compiler" thing is to enable...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.