Q
Quizical
First, is null considered a Value Type or a Reference Type.
I have a question about performance and memory. Does the performance
change or the amount of memory that is consumed when you have a
difference in flow control statements as follows:
//Arbitrary Reference Type
Mailmessage mm = new Mailmessage();
//A
if (null != mm)
{
Console.WriteLine(mm.ToString());
}
Or
//B
if (mm != null)
{
Console.WriteLine(mm.ToString());
}
I have been told that A performs better since the CLR does not have to
make a copy of the value null, I think it doesn't matter since both
values must be checked regardless. (I also think this reads like crap)
Please Help!
I have a question about performance and memory. Does the performance
change or the amount of memory that is consumed when you have a
difference in flow control statements as follows:
//Arbitrary Reference Type
Mailmessage mm = new Mailmessage();
//A
if (null != mm)
{
Console.WriteLine(mm.ToString());
}
Or
//B
if (mm != null)
{
Console.WriteLine(mm.ToString());
}
I have been told that A performs better since the CLR does not have to
make a copy of the value null, I think it doesn't matter since both
values must be checked regardless. (I also think this reads like crap)
Please Help!