zfbj 发表于 2004-4-22 15:07:00

[求助]请教goldenshin,C#开发ARX的简单程序

// 创建多行文字
               
                public static void HelloText()
                {
                        MText text = null;
                        BlockTable bt = null;
                        BlockTableRecord btr = null;                       
                        try
                        {
                                Database db = HostApplicationServices.WorkingDatabase;
                                ObjectId objId = db.BlockTableId;
                                // 打开块表,注意使用的函数为ObjectId.Open()
                                bt = (BlockTable)objId.Open(OpenMode.ForRead);
                                objId = bt.this(BlockTableRecord.ModelSpace);
                                btr = (BlockTableRecord)objId.Open(OpenMode.ForWrite);
                                // Create new mtext and set text
                                text = new MText();
                                text.SetContents("Hello World!!");
                                // Append entity to model space
                                btr.AppendEntity(text);
                        }
                        catch
                        {
                                // no error checking
                        }
                        finally
                        {
                                text.Close();
                                btr.Close();
                                bt.Close();
                        }
                }
其中的“bt.this”在VB.NET中对应代码为“bt.Item”,但是在C#中this是保留的关键字,因此程序编译出错,但是应该如何调用呢?

zfbj 发表于 2004-4-23 10:26:00


已经解决这个问题,只要将bt.this换成bt即可通过。
这是C#中索引器的使用方法。
页: [1]
查看完整版本: [求助]请教goldenshin,C#开发ARX的简单程序