Is it possible to have a dynamic operator in c#?
string aString = "5";
int a = 5;
int b = 6;
string op = "<";
//want to do something like dynamically without checking the value of op
if( a op b)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t create dynamic operators – but you can wrap an operator in a delegate. You can use lambdas to simplify the syntax.
Although it’s not definite – the future direction for C# is to implement the compiler as a service. So, at some point, it may be possible to write code that dynamically evaluates an expression.