Jon*_*eet 30
据推测,它被认为不值得包含在内.
如果您愿意,可以轻松地将其添加为扩展方法(如果您使用的是C#3):
public static Point Center(this Rectangle rect)
{
return new Point(rect.Left + rect.Width/2,
rect.Top + rect.Height / 2);
}
Run Code Online (Sandbox Code Playgroud)
请注意,由于值表示为整数,因此您可能很容易得到一个非精确值,假设您想要Point使用decimal或返回一个而不是另一个结构double.
以上实际上是针对System.Drawing.Rectangle 结构的.如果您正在谈论不同的矩形,请添加相应的信息,我将编辑我的答案.