What is the output from the following code
using System; struct Point{ int x, y; public Point (int x, int y) { this.x = x; this.y = y; } public Point () { this.x = 10; this.y = 20; } } class MainClass{ public static void Main(string[] args){ Point p1 = new Point (); Point p2 = new Point (1, 1); Console.WriteLine(p1.x); Console.WriteLine(p2.x); } }
public Point () { //Illegal: parameterless constructor
You cannot declare a parameterless constructor for the struct you created.
The parameterless constructor is added by compiler.