I would like to know which gives us a better performs on both the ways as given below:
1. Way 1
for(int i = 0; i < 10; i++) { // do something in loop }
2. Way 2
for(int i = Constants.Zero; i < Constants.Ten; i++) { // do something in loop }
private const int Zero = 0;
private const int Ten = 10;
Basically I want to know that Can we increase the application performance if we use Constants in for loop variable declaration as mentioned above?
Thanks in advance !
There is no any performance benefit here, as variable declared in that way will end up into injected constants, like in your first case. So they are become basically the same.
In second case I used a
staticclass to create constants.