While Java has a 'Point2D structure, to my knowledge, C# does not.
C# has 'Point, and 'PointF. 'PointF is sealed, so you can't inherit from it. However, assuming you want to be able to handle both integer C# Point, and other numeric-Type C# Types, you can do something like this:
public class PointXY<T> where T :
struct,
IComparable,
IFormattable,
IConvertible,
IComparable<T>,
IEquatable<T>
{
private static PointXY<T> _origin;
public static PointXY<T> Origin
{
private set { _origin = value; }
get { return _origin; }
}
public PointXY()
{
}
public PointXY(T ox, T oy)
{
if (Origin == null)
{
Origin = new PointXY<T>();
Origin.X = ox;
Origin.Y = oy;
}
}
private T _x;
public T X
{
get { return _x; }
set { _x = value; }
}
private T _y;
public T Y
{
get { return _y; }
set { _y = value; }
}
}
Consider the result of this test, however:
PointXY<int> p1 = new PointXY<int>(32, 99);
PointXY<int> p1a = new PointXY<int>(132, 199);
PointXY<double> p2 = new PointXY<double>(23.4, 32.4);
Console.WriteLine("{0} {1}, {2}", p1.Origin, p1.Origin.X, p1.Origin.Y);
Console.WriteLine("{0} {1}, {2}", p1a.Origin, p1a.Origin.X, p1a.Origin.Y);
Console.WriteLine("{0} {1}, {2}", p2.Origin, p2.Origin.X, p2.Origin.Y);
PointXY`1[System.Int32] 32, 99
PointXY`1[System.Int32] 32, 99
PointXY`1[System.Double] 23.4, 32.4</double></double></int></int></int></int>
You'll note that in this code, once you've set the 'Origin for one specific Type, then you can't reset it. That may not be what you want, but it would be easy enough to add some kind of over-ride to let the 'Origin be reset based on certain criteria.