CodeDom conditional expression.

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top