Yes, you're just adding the same object reference three times. ;P The last run on the
for
loop sets the values to what you'll see for all rows, since all rows point to the same instance of Testing.
You were really close. Instead, do this:
for (int i = 0; i <= counting2;i++ )
{
Testing Hello = new Testing();
Hello.year = array[counting2, 0];
Hello.One = array[counting2, 1];
Hello.Two = array[counting2, 2];
Hello.Three = array[counting2, 3];
Hello1.Add(Hello);
}
dataGrid1.ItemsSource = Hello1;
It's okay to have the Testing variable Hello scoped only within the
for
loop. In fact, this is how you'll get a new object reference to add to the list.