Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualnobodynews

Posted 02 February 2013 - 09:44 PM

Microsoft offers a clear explanation here. The important part is under the initializing value types section. Basically, the first way doesn't initialize the variable and you must initialize variables bofore you can use them in C#. So you have to assign a value to the variable before you could use it or you'll get a compiler error.  The second way calls the default constructor for an int type which that links says is equivalent to doing this: int a = 0;

 

I doubt there's any performance difference between the two methods.


#1nobodynews

Posted 02 February 2013 - 09:38 PM

Microsoft offers a very clear explanation here. The important part is under the initializing value types section. Basically, the first way you show doesn't initialize the variable and you must initialize values bofore you can use them in C#. The second way you show calls the default constructor for an int type which that links says is equivalent to doing this: int a = 0;


PARTNERS