We have class Shape, that has only two properties (int CoordC, int CoordY).
And we have List<Shape>.
Next step
Two test functions like:
public void TestFunc1()
{
int count = shapes.Count;
string result = "";
for (int i = 0; i < count; i++)
{
result += "Shape " + i + shapes[i].CoordX.ToString() + "\r\n";
}
}
public void TestFunc2()
{
string result = "";
for (int i = 0; i < shapes.Count; i++)
{
result += "Shape " + i + shapes[i].CoordX.ToString() + "\r\n";
}
}
Lets play the game? Why TestFunc2 will be faster? Count, of List items, doesnt matter.
Hi.
ОтветитьУдалитьI have a TestFunc1 faster.