Fill an empty arrary/list in C# with values of a variable

  • Thread starter Thread starter juanrendonls96
  • Start date Start date
J

juanrendonls96

Guest
Hi, I am kind of new in C#. Just a simple question, I am having trouble to store the values of a changing variable in a list or array. The variable who is constantly changing is movingPointIdx, but it does not store the values and sort them. Thank you

List<int> listXpoints = new List<int>();
listXpoints.Add(movingPointIdx); //movingPointIdx: int variable, which takes different values
listXpoints.Sort();

foreach (int i in listXpoints)
{
Console.WriteLine(i);
}

Continue reading...
 
Back
Top