.net - Comparer.Compare needs one Object that implements IComparable but will throw exception if not the first parameter is -
In order to compare the function in a comparative class, the document says:
One tool applies, then one. Compare (B) has been refunded; Otherwise, if B has implemented the ii copperball, then the denial of B. is the result. Compare (A) is returned.
But when I test it, it grows fast as it demands that the first input to Icomparable will apply to the following code:
class program {static zero main (string [] args) {test t1 = new test (); Test 2 T2 = New Test 2 (); Int i = equalizer Default.computer (T1, T2); }} Class Test {} Class Test 2: ICAPPable {Public Entry Quota (Object OBJ) {Return 0; }}
Is it just me or what is wrong?
The detector says that it only checks when an IMPM is applicable. Public ent (object A, object b) (if (a == b) {return 0;} if (a == blank) {return -1;} if (b == Blank) {return1;} if (this.m_compareInfo! = Null) {string str = a as string; string as str2 = b string; if ((str! = Null) & amp; (str2! = Null)) {This return.m_compareInfo.Compare (str, str2);}} IComparable = comparable = IComparable as a; if (comparable == faucet) {new argument expression (environment; gatoros string ("argument_value");) ;} Returns comparable. CompareTo (B);
}
Comments
Post a Comment