V
Vagif Abilov
After porting some code from .NET 1.1 to .NET 2.0 I got a problem with some
static variables (reference types) that were not set to null. I received the
following comment on it:
"only in vb.net are un-initialozed variables set to null. in c# you need to
do it yourself, as the compiler doesn't emit and initalation code you don't
include. its a bug in your code. its just luck it worked in 1.1"
I must say that if this it true, it means I was completely misunderstanding
the way .NET initialized reference type instances. I thought they are set to
null, i.e. the following declarations of a1 and a2 are equal:
class A
{
....
}
class B
{
....
A a1 = null;
A a2;
}
If they are not, then what a2 is initialized to?
TIA
Vagif Abilov
Oslo Norway
static variables (reference types) that were not set to null. I received the
following comment on it:
"only in vb.net are un-initialozed variables set to null. in c# you need to
do it yourself, as the compiler doesn't emit and initalation code you don't
include. its a bug in your code. its just luck it worked in 1.1"
I must say that if this it true, it means I was completely misunderstanding
the way .NET initialized reference type instances. I thought they are set to
null, i.e. the following declarations of a1 and a2 are equal:
class A
{
....
}
class B
{
....
A a1 = null;
A a2;
}
If they are not, then what a2 is initialized to?
TIA
Vagif Abilov
Oslo Norway