CodeDom conditional expression.

G

Guest

I would like to know the sequence of calls required to create a conditional
expression like:

if(a != null)
{
}

So far I have only come up with

if(a)
{
}

Which will work but I would like to know how to form expressions with '!=',
'==', '>', etc.

Thank you for your help.

Kevin Burton
 
D

Damien

Kevin said:
I would like to know the sequence of calls required to create a conditional
expression like:

if(a != null)
{
}

So far I have only come up with

if(a)
{
}

Which will work but I would like to know how to form expressions with '!=',
'==', '>', etc.

Thank you for your help.

Kevin Burton

Hi Kevin,

It would have helped if you'd posted the code you had already, so we
could work and adapt from that. Here's some code from one of my
projects, in VB, but should be amenable to use in C# if that's your
poison:

ifActualChange.Condition = New
CodeBinaryOperatorExpression(col.mVarRef,
CodeBinaryOperatorType.IdentityInequality, __Nothing)

where col.mVarRef is a property that returns a
CodeVariableReferenceExpression, and __Nothing is a global variable set
to a CodePrimitiveExpression of Nothing (you'd use a
CodePrimitiveExpression of null in C#).

You should find that CodeBinaryOperatorExpression meets most of your
needs, although I've found it to be curiosly limitied in some places in
the past.

Damien
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top