// Reference equality: two objects, same boxed value
objects = 1;
objectt = 1;
Console.WriteLine(s != t);
// String equality: same string value, same string objects
stringa = "howdy";
stringb = "howdy";
// compare string values
Console.WriteLine(a != b);
// compare string references
Console.WriteLine((object)a != (object)b);
Enter to Rename, Shift+Enter to Preview
About C# != Operators
The inequality operator (!=) returns false if its operands are equal, true otherwise. Inequality operators are predefined for all types, including string and object. User-defined types can overload the != operator.
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.