View Single Post
Old 09-12-2008, 10:51 AM   #4 (permalink)
jaeusm
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default Re: Quick Nooby Question, C#

Quote:
Before they are set to zero there's just random garbage from memory in each of those variables.
This is C# we're talking about here. Class variables are initialized to 0 (or null if an object, and false if a boolean) by the CLR when the class is instantiated, so there's never any random garbage in the values. If the programmer manually initializes the values of class variables to 0, the C# compiler will emit the extra instructions to set memory to 0 again, which is inefficient. So it's not wrong, but it's definitely inefficient.
jaeusm is offline