我写了个结构 public struct Coordinate
{
// Data
private double x;
private double y; // Operator
public static implicit operator PointF(Coordinate c)
{
return new PointF((float)c.X, (float)c.Y);
} // ...
}如何在 将Coordinate[] 转换为 PointF[]
{
// Data
private double x;
private double y; // Operator
public static implicit operator PointF(Coordinate c)
{
return new PointF((float)c.X, (float)c.Y);
} // ...
}如何在 将Coordinate[] 转换为 PointF[]
public struct Coordinate
{
// Data
private double x;
private double y; private Dictionary<int, Coordinate> dict = new Dictionary<int, Coordinate>();
public Coordinate this[int index]
{
get
{
if (dict.ContainsKey(index))
{
return dict[index];
}
else
{
throw new ArgumentOutOfRangeException();
}
}
set
{
if (dict.ContainsKey(index))
{
dict[index] = value;
}
else
{
dict.Add(index, value);
} }
}
}
{
return new PointF((float)c.X, (float)c.Y);
}
//你这里并没有数组的转换操作呀?
Point[] points = (Coordinate[])coordinates;想只在 Coordinate类中添加代码完成者个转换,而不是在需要的地方遍历转换。
Point[] points = (Point[])coordinates;想只在 Coordinate类中添加代码完成者个转换,而不是在需要的地方遍历转换。