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 / New Users / July 2007

Tip: Looking for answers? Try searching our database.

Can ternary conditional expressions be represented in the CodeDOM?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas W. Brown - 10 Jul 2007 01:08 GMT
... I know I could use a CodeSnippetExpression to do it, but that would
somewhat hardcode the resulting tree.  I was looking for something like:

  CodeTernaryExpression(
     CodeExpression test,
     CodeExpression trueExpression,
     CodeExpression falseExpression);

Which would, of course, get turned into the corresponding:

  (test ? trueExpression : falseExpression)

expression in C#, C++, or even J# (I believe).  I guess it's only VB.NET
that doesn't have a ternary expression but I don't know for sure.

I know, I know, for generated code there's no real reason to use a ternary
expression, but coding habits are hard to break, even when writing meta-code
:-)

Regards,
-- TB
AMercer - 10 Jul 2007 13:56 GMT
> I guess it's only VB.NET
> that doesn't have a ternary expression but I don't know for sure.

VB does have such an expression, it is IIF.  Be advised that the semantics
are different - both the true and false expressions are evaluated regardless
of the value of the test expression.
Damien - 10 Jul 2007 14:32 GMT
On Jul 10, 1:08 am, Thomas W. Brown
<thomas_w_br...@countrywide.NOSPAM.com> wrote:
> ... I know I could use a CodeSnippetExpression to do it, but that would
> somewhat hardcode the resulting tree.  I was looking for something like:
[quoted text clipped - 17 lines]
> Regards,
> -- TB

There are more surprising ommissions from the CodeDom than ternary
expressions - things you would expect to find in ANY language (and as
AMercer pointed out, VB does have IIF).

For instance, try looking for:
Unary Minus
Xor
Value Inequality

Or try generating a while loop. Or a lock expression (Synclock in VB).
Or a Negative test (If Not xxxxx in VB/if(!xxxxx) in C#)

Damien

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.