Is it possible to hide the parameterless constructor from a user in c#
I want to force them to always use the constructor with parameters
e.g. this Position class
public struct Position
{
private readonly int _xposn;
private readonly int _yposn;
public int Xposn
{
get { return _xposn; }
}
public int Yposn
{
get { return _yposn; }
}
public Position(int xposn, int yposn)
{
_xposn = xposn;
_yposn = yposn;
}
}
I only want users to be able to new up a Position by specifying the x and y coordinates
However, the parameterless constructor is ALWAYS availiable
I cannot make it private. Or even define it as public
I have read this http://stackoverflow.com/questions/333829/why-cant-i-define-a-default-constructor-for-a-struct-in-net
but it doesnt really help
If this is not possible - what is the best way to detect if the Position I am being passed has values?
Explicity checking each property field? Is there a slicker way?
thanks