关于foreach不能在“方法组”上执行,怎样理解?
我写的一个方法,提示public static void 选择1()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult ent = ed.GetEntity("\n 请选择直线");
ObjectId id = ent.ObjectId;
using (Transaction trans1 = doc.TransactionManager.StartTransaction())
{
Entity ent1 = (Entity)id.GetObject(OpenMode.ForRead);
PromptSelectionResult per = ed.SelectOnLine((Line)ent1);
SelectionSet ss = per.Value;
using (Transaction trans2 = doc.TransactionManager.StartTransaction())
{
//遍历选择集中的对象,修改颜色为红色
foreach (ObjectId id1 in ss.GetObjectIds)
{
Entity ent2 = (Entity)trans2.GetObject(id1, OpenMode.ForRead);
ent2.ColorIndex = 1;
}
trans2.Commit();
}
trans1.Commit();
}
}
提示 foreach不能在“方法组”上执行,是什么意思,请高手赐教 查了一下,少了一对“()”,应该是 foreach (ObjectId id1 in ss.GetObjectIds())
不好意思,给大家添麻烦了,我不是故意刷屏的。
页:
[1]