public static unsafe bool Equals (string a, string b) { if ((a as object) == (b as object)) return true; if (a == null || b == null) return false; int len = a.length; if (len != b.length) return false; if (len == 0) return true; fixed (char * s1 = &a.start_char, s2 = &b.start_char) { // it must be one char, because 0 len is done above if (len < 2) return *s1 == *s2; // check by twos int * sint1 = (int *) s1, sint2 = (int *) s2; int n2 = len >> 1; do { if (*sint1++ != *sint2++) return false; } while (--n2 != 0); // nothing left if ((len & 1) == 0) return true; // check the last one return *(char *) sint1 == *(char *) sint2; } }