[ACCEPTED]-string1 >= string2 not implemented in Linq to SQL, any workaround?-string-comparison

Accepted answer
Score: 30

If you're looking for => which would normally 7 be written as >= then you cannot do this directly 6 with strings. You can get the same behaviour 5 via CompareTo:

string1.CompareTo(string2) >= 0

In this case, the result being less 4 than or equal to zero means that string1 would 3 be sorted before string2 and therefore is greater.

FYI 2 the => operator in C# is only used in the 1 definition of lambda expressions.

Score: 8

string1 >= string2 is not supported in 7 C# Linq To Sql. The String class does not 6 override the >= operator at all. It 5 only overrides the != and == operators. You 4 can verify this by trying to compile the 3 following method

public static void Example() {
  int val = "foo" >= "bar";

If you want to compare to 2 Strings in LinqToSql you should be able 1 to use the static String.Compare(string,string) method.

More Related questions