225.
Replacing the word struct with class, will the code below compile
public struct Point
{
public int x, y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
}
class MainClass
{
public static void Main()
{
// Declare an object:
Point myPoint;
// Initialize:
myPoint.x = 10;
myPoint.y = 20;
// Display results:
Console.WriteLine("My Point:");
Console.WriteLine("x = {0}, y = {1}", myPoint.x, myPoint.y);
}
}
View Description
It won't compile because myPoint.x = 10; and myPoint.y = 20; first need to be initialized by using the 'new' keyword as Point myPoint = new Point();