export enum Decisions {
approve = 'approve',
reject = 'reject'
}
export type DecisionsTypeUnion =
Decisions.approve |
Decisions.reject;
if (decision in Decisions) {
// valid
}
我要检查矩形坐标是否正确存储在数组中。但是我不知道如何打印出该值。
答案 0 :(得分:1)
您必须访问要显示的属性:
foreach(System.Drawing.Rectangle rect in _rectangleList)
{
MessageBox.Show($"X:{rect.X} Y:{rect.Y} Width:{rect.Width} Height:{rect.Height}");
}
您也可以在填充数组时简单地设置一个断点,并使用调试器检查其内容。如果使用的是Visual Studio,则可以将插入号放在数组上,然后按Shift-F9键查看内容(或从菜单中选择 Quick Watch )。
答案 1 :(得分:0)
在MessageBox中打印坐标:
MessageBox.Show("X:" + rect.Location.X + " Y:" + rect.Location.Y);
答案 2 :(得分:0)
对于矩形高度,您必须说 矩形高度
答案 3 :(得分:0)
You can create your own extension method on the rectangle that will print out all the details that you .
Check my example here.
public static class RectangleExtensions
{
public static string Details(this System.Drawing.Rectangle rectangle)
{
var details = new StringBuilder();
details.AppendFormat("Height: {0}", rectangle.Height);
details.AppendFormat("Bottom: {0}", rectangle.Bottom);
details.AppendFormat("Left: {0}", rectangle.Left);
details.AppendFormat("Right: {0}", rectangle.Right);
return details.ToString();
}
}
class Program
{
static void Main(string[] args)
{
var rectangle = new System.Drawing.Rectangle();
Console.WriteLine(rectangle.Details());
}
}