zzzprojects / Eval-Expression.NET

C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
https://eval-expression.net/
Other
449 stars 86 forks source link

Unable to use compare operator between two strings #116

Closed amarendravanipenta closed 3 years ago

amarendravanipenta commented 3 years ago

I have been trying to evaluate an expression of string comparison. But I was getting a run time error. Below is the snippet of the compiler with the error.

For Numeric:

image

For Strings :

image

We are able to compare numeric or boolean values. But not the strings. Is there any way to do that or the error was as expected?

Any response would be appreciated.

Thanks, Amarendra.

JonathanMagnan commented 3 years ago

Sure we can compare easily string: https://dotnetfiddle.net/kONyU0

But in your example, your “female” is currently not considered a string but a variable since there is no quote. So that’s why you get the current error.

So that’s possible, but only if you let our library know that your string is a string 😉

Let me know if that answers correctly to your request.

Best Regards,

Jon

amarendravanipenta commented 3 years ago

Perfect! Thanks for the quick assistance.