I have some code to initialize a struct in C#:
namespace Practice
{
public struct Point
{
public int _x;
public int _y;
public int X
{
get { return _x; }
set { _x = value; }
}
public int Y
{
get { return _y; }
set { _y = value; }
}
public Point(int x, int y)
{
_x = x;
_y = y;
}
}
class Practice
{
public static void Main()
{
Point p1;
p1.X = 1;
p1.Y = 2;
}
}
}
The above code gives a compiler error:
error CS0165: Use of unassigned local variable 'p1'
Why is this error being thrown?