几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(VB.NET/C#) (http://www.dimcax.com/hust/forumdisplay.php?f=176)
-   -   【转帖】switch 判断对象类型问题 (http://www.dimcax.com/hust/showthread.php?t=8982)

yang686526 2009-04-20 12:21 PM

【转帖】switch 判断对象类型问题
 
switch 判断对象类型问题
www.dimcax.com
switch 判断对象类型问题
switch (ent.gettype())
{
case polyline:
polyline ent = (polyline)ent;
changeplineattrib(ent, tbl);
break;
case dbpoint:
dbpoint ent = (dbpoint)ent;
changepointattrib(ent, tbl);
break;
}
我用这种方法判断对象的类型,提示ent是非整形
这个需要怎么改啊?谢谢
自己看看ent.gettype()返回的是什么?跟你case后的类型是对应的吗?照着改就是了
switch (ent.gettype()tostring().replace("autodesk.autocad.databaseservices.", ""))
{
case "polyline":
polyline ent = (polyline)ent;
changeplineattrib(ent, tbl);
break;
case "dbpoint":
dbpoint ent = (dbpoint)ent;
changepointattrib(ent, tbl);
break;
}
复制代码
[
非常感谢。在case "":代码段加个{}就可以编译通过了


所有的时间均为北京时间。 现在的时间是 10:33 AM.