I'd like to print all ten random generated points for each object in the ArrayList AL.
public class Point
{
public int x;
public int y;
public Point(int x, int y)
{
x = this.x;
y = this.y;
}
}
public class ArrayListTest
{
public static void Main(string[] args)
{
ArrayList AL = new ArrayList();
Random Rnd = new Random();
for (int i = 1; i <= 10; i++)
{
Point p = new Point(Rnd.Next(50), Rnd.Next(50));
AL.Add(p);
}
PrintValues(AL);
}
public static void PrintValues(IEnumerable myList)
{
foreach (Object obj in myList)
Console.WriteLine("{0} ", obj);
}
}
Output on console:
Point
Point
Point
Point
Point
Point
Point
Point
Point
Point
My Problem is, that the classname of the object printed and not the values of the objects. I am using .NET Framework v4.8