Io uso questo codice e ottenere risultato vero:Come confrontare due oggetti con valori stringa?
object text1 = "test";
object text2 = "test";
Console.WriteLine("text1 == text2 : " + (text1 == text2));
//return:true
Ma quando provo a più bassa: object text2 = "test".ToLower();
ottengo false
risultato?
object text1 = "test".ToLower();
object text2 = "test".ToLower();
Console.WriteLine("text1 == text2 : " + (text1 == text2));
//return:false
In realtà, l'operatore di uguaglianza mira al ** valore **, non al riferimento: http://msdn.microsoft.com/en-us/library/system.string.op_equality.aspx –
Ok, ora I ' ho visto il tuo aggiornamento. Object '==' mira al riferimento. –
@AndreCalil 'String.Equality' fa, ma' Object.Equals' usa l'uguaglianza di riferimento, che è quello che ho detto. –