G
Guest
In VB you can test if a value type has the "default" value by doing the
following:
dim i as integer
if (Nothing = i) then
'* i is really 0
end if
Now, when I try to do this in C# of course it doesn't work because you can't
do:
int i;
if ( null == i) {
// i is 0
}
of course because you can't compare null == i.
Now, in this case I know, and you know, that an int defaults to 0, but there
are lots of types that default to some value that I don't know, e.g.
System.Drawing.Color.
Can anyone tell me how I can check if a value type is equal to its default
value?
following:
dim i as integer
if (Nothing = i) then
'* i is really 0
end if
Now, when I try to do this in C# of course it doesn't work because you can't
do:
int i;
if ( null == i) {
// i is 0
}
of course because you can't compare null == i.
Now, in this case I know, and you know, that an int defaults to 0, but there
are lots of types that default to some value that I don't know, e.g.
System.Drawing.Color.
Can anyone tell me how I can check if a value type is equal to its default
value?