Sorry, you cannot create your own statements in C #.
You can use extension methods to enable free syntax like
bool f = b.IsBetween(a, c);
Or, if you were very smart, you could do:
bool f = a.IsLessThan(b).IsLessThan(c);
it is difficult to do, but possible. (Hint: defining a custom object that IsLessThan returns, tracks its boundaries and understands how it blends with other instances of the object. Essentially, this is how LINQ-to-SQL works with respect to joining Where, Select, etc.) .
But you cannot define your own operator syntaxes in C #.
If you are interested in languages โโin which you can define your own operators, you can consider searching in F #.
Eric Lippert
source share