Skip to content

Instantly share code, notes, and snippets.

@MattRix
Last active December 29, 2015 17:58
Show Gist options
  • Select an option

  • Save MattRix/7707294 to your computer and use it in GitHub Desktop.

Select an option

Save MattRix/7707294 to your computer and use it in GitHub Desktop.
C# declaration example
//These have *identical* performance
Car myCar = new Car();
//STYLE A: with declaration outside loop
Car tempCarA;
for(int c = 0; c<1000; c++)
{
tempCarA = myCar;
tempCarA.Honk();
}
//STYLE B: with declaration inside loop
for(int c = 0; c<1000; c++)
{
Car tempCarB = myCar;
tempCarB.Honk();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment