4
I need to change the following foreach()
by a for()
. The problem is that instead of arrays the loop runs through a dictionary.
This is the code I want to transform for()
:
foreach (var joint in body.Joints.Values) //transformar em um for para usar valoren anteriores
{
eixoX = joint.Position.X.ToString();
eixoX = eixoX.Replace(",", ".");
line.Append(eixoX + ",");
eixoY = joint.Position.Y.ToString();
eixoY = eixoY.Replace(",", ".");
line.Append(eixoY + ",");
}
For not mastering C# I was confused to do this.
Link to the implementations of class.
I don’t think this is going to be a problem in practice, but I understand that
.ElementAt(index)
generally takes time O(index)? I do not know what thepmargreff
wants to do, but the possibility of creating aList<T>
orT[]
temporary and use this temporary object may best suit what he wants.– user25930
Worked, grateful.
– pmargreff
I thought the list idea was cool.
– pmargreff