If I have a code like this
for(int i=0;i<10;i++)
{
int iTemp;
iTemp = i;
//.........
}
Does the compiler instantinate iTemp 10 times?
Or it optimize it?
I mean if i rewrite the loop as
int iTemp;
for(int i=0;i<10;i++)
{
iTemp = i;
//.........
}
Will it be faster?
Using reflector you can view the IL generated by the C# compiler.
They’re exactly the same so it makes no performance difference where you declare iTemp.