using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
namespace AcadNetSamples
{
public class Commands
{
[CommandMethod("LOOPS")]
public static void LoopOperations()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
string[] strs = new string[10];
int i;
for (i = 0; i < 10; i++)
{
strs[i] = "String No. " + (i + 1).ToString();
}
ed.WriteMessage("\n\nUsing 'foreach' Loop\n");
foreach (string str in strs)
{
ed.WriteMessage("\n\t\t" + str);
}
ed.WriteMessage("\n\nUsing 'While' Loop\n");
i = 0;
while (i < 10)
{
ed.WriteMessage("\n\t\tString No. " + (i + 1).ToString());
i++;
}
ed.WriteMessage("\n\nUsing 'Do While' Loop\n");
i = 0;
do
{
ed.WriteMessage("\n\t\tString No. "+ (i + 1).ToString());
i++;
} while (i < 10);
}
}
}
Sunday, August 5, 2007
Iterations in C#
As I mentioned in the last post, in this session, we are going to cover the loop structures in C#. Our primary aim is to concentrate more on the syntax of loops. Here is a sample which shows iteration results in AutoCAD prompt using different looping methods.
Labels:
AutoCAD Programming,
AutoCAD.Net,
Sample Code
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment