Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / May 2006

Tip: Looking for answers? Try searching our database.

CodeDom : CLR 2.0 Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Russell Mangel - 03 May 2006 18:28 GMT
I am using C# 2.0 and the CodeDom.

Can someone answer the following 3 questions about the CodeDom in CLR 2.0.

1. I understand that there is no while() loop, only for( ; ; ) loop, can
anyone confirm this.
2. I understand that there is no switch() statement, can anyone confirm
this.
3. I need to create the following code in the CodeDom, can someone show me
how to do this:

String[]s={new String('X', 5),new String('Y',10),new String('Z',15)};

The CodeDom will generate the previous line of code in a loop, so there
could be any number of elements in the String[] array. Is it possible to do
this with the CodeDom, or will i have to generate all the elements one at a
time and then add them by it's index?

Thanks

Russell Mangel
Las Vegas, NV
Greg Young - 05 May 2006 01:13 GMT
1) from
http://msdn2.microsoft.com/en-us/library/system.codedom.codeiterationstatement.aspx
A CodeIterationStatement can represent a for loop or while loop.

This is interesting but I have never actually been able to get it to
generate a while loop ... Maybe someone else on the ng has, if so I would be
quite interested to hear about it! My guess is that the documentation is
wrong

2) from http://blogs.msdn.com/bclteam/archive/2005/03/16/396915.aspx

Switch statement: CodeDom doesn't support a way to generate switch (select
statement in VB) statement. We recommend CodeDom users to use the
'multiple/nested if satements' as a work around.

3) You can define the array values using a CodeArrayCreateExpression
http://msdn2.microsoft.com/en-us/library/system.codedom.codearraycreateexpressio
n.aspx

the particular overload you are looking for is
http://msdn2.microsoft.com/en-us/library/ms131644.aspx which takes a
CodeExpression [] that represents the values to initialize the array with.
http://blogs.msdn.com/roberthorvick/archive/2004/03/15/89818.aspx includes
an example.

Cheers,

Greg

>I am using C# 2.0 and the CodeDom.
>
[quoted text clipped - 18 lines]
> Russell Mangel
> Las Vegas, NV

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.