Well, if the float is high enough precision, you can use PointF struct :
var point = new PointF(3.5f, 7.9f);
If you really need to, you can define your own PointD structure:
public struct PointD { public double X; public double Y; public PointD(double x, double y) { X = x; Y = y; } public Point ToPoint() { return new Point((int)X, (int)Y); } public override bool Equals(object obj) { return obj is PointD && this == (PointD)obj; } public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); } public static bool operator ==(PointD a, PointD b) { return aX == bX && aY == bY; } public static bool operator !=(PointD a, PointD b) { return !(a == b); } }
The equality code is from here .
The ToPoint() method allows you to convert it to a Point object, although, of course, the accuracy will be truncated.
Cameron
source share