Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does anyone know of a .NET enum of Comparison Operators in System or System.Core?

Tags:

Is there an enum in System or System.Core that has all the ComparisonOperators?

I just wrote the following enum, but it seems like a common enough thing that one might already exist.

public enum ComparisonPredicate {     Equal,     Unequal,     LessThan,     LessThanOrEqualTo,     GreaterThan,     GreaterThanOrEqualTo } 

I found one in System.Web.UI, but it would be more than silly to introduce a dependency for that http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.validationcompareoperator(v=VS.100).aspx

Also, I already looked at ExpressionType, but I don't want something with that broad of a scope

like image 215
smartcaveman Avatar asked Apr 28 '11 14:04

smartcaveman


People also ask

What is enum in .NET core?

The enum keyword in C# and . NET is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list. Usually, an enum is declared as public within a namespace and is available to all classes in the namespace.

How many comparison operators are there?

There are four types of operators that can be used in expressions: comparison.

What are the 6 comparison operators?

A comparison operator compares two values and returns a boolean value, either True or False . Python has six comparison operators: less than ( < ), less than or equal to ( <= ), greater than ( > ), greater than or equal to ( >= ), equal to ( == ), and not equal to ( != ).


2 Answers

A bit late, but .Net 3.5 introduced the ExpressionType enumeration in System.Linq.Expressions, see http://msdn.microsoft.com/en-us/library/bb361179(v=vs.110).aspx for more details.

like image 156
Richard Schneider Avatar answered Oct 08 '22 08:10

Richard Schneider


AFIK such a thing does not exist. You are probably better off using your own, for now.

like image 27
Muad'Dib Avatar answered Oct 08 '22 07:10

Muad'Dib