如何检查对象是矩形还是椭圆
How can I check if an object is a Rectangle or an Ellipse
如何检查创建的对象是矩形还是椭圆在 WPF 中?
Ellipse ellipse = new Ellipse();
Rectangle rect = new Rectangle();
if (rect.getType()){
rect.Margin = new Thickness(x,y,0,0);
} else {
ellipse.Margin = new Thickness(x, y, 0, 0);
}
使用 is
keyword 您可以检查对象的类型。
if(rect is Rectangle)
如何检查创建的对象是矩形还是椭圆在 WPF 中?
Ellipse ellipse = new Ellipse();
Rectangle rect = new Rectangle();
if (rect.getType()){
rect.Margin = new Thickness(x,y,0,0);
} else {
ellipse.Margin = new Thickness(x, y, 0, 0);
}
使用 is
keyword 您可以检查对象的类型。
if(rect is Rectangle)