Parse a IF Condition written in the String to C# Code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Walmik
    New Member
    • Jan 2012
    • 1

    Parse a IF Condition written in the String to C# Code

    Example:

    Condition:

    IF A > B THEN

    PRINT B

    ELSE

    PRINT A


    This condition is written as a string in coloumn of the table in SQL.

    I want to fetch this condition from the table and convert this condition to the C# Code as

    If(A > B )

    {

    print B...........

    }

    else

    {

    print A...........

    }


    Where A and B are the Dynamic values passed in the C#.
  • ranjaniVinsInfo
    New Member
    • Jan 2012
    • 34

    #2
    use return parameter in sqlserver.

    check the column value equal to ( IF A > B THEN PRINT B ELSE PRINT A )

    if this is true means, return [ IF A > B {PRINT B }ELSE{ PRINT A}]

    Comment

    • PsychoCoder
      Recognized Expert Contributor
      • Jul 2010
      • 465

      #3
      Just for the record, you cannot check if a string is greater than another string, so the way you're looking at it it wont ever catch your condition.

      Best way would to be use the return parameter (as already mentioned) and have it check for a and b and return an integer value for each

      Comment

      Working...