Right now we have two structs to represent 2d points.
public struct Point2D
{
public double X { get; set; }
public double Y { get; set; }
}
public struct Point2DF
{
public float X { get; set; }
public float Y { get; set; }
}
Now we need to make another struct to represent 2d point for intergers.
public struct Point2DI
{
public int X { get; set; }
public int Y { get; set; }
}
My question is should I use generics here? If I use generics I will have one single struct instead of three.
public struct Point<T>
{
public T X { get; set; }
public T Y { get; set; }
}
But consumer can set T as string or some class/struct. What should I do? Is there any way I can force T to be double/int/float?