using System; using System.Diagnostics; using System.Threading; namespace UsingIsEqualsComparison { public class Program { public static void Main() { Thread.Sleep(1000); Debug.WriteLine("Hello from nanoFramework!"); try { // try with an int int x = 0; int y = 0; Debug.WriteLine($"X.Equals(y):{x.Equals(y)}"); Debug.WriteLine($"X.Equals(0):{x.Equals(0)}"); // try with a string string a = "a"; string b = "b"; Debug.WriteLine($"X.Equals(a):{a.Equals(b)}"); Debug.WriteLine($"X.Equals(null):{a.Equals(null)}"); AnEnum e1 = AnEnum.A; AnEnum e2 = AnEnum.B; Debug.WriteLine($"e1.Equals(e1):{e1.Equals(e1)}"); Debug.WriteLine($"e1.Equals(e2):{e1.Equals(e2)}"); Debug.WriteLine($"e1.Equals(AnEnum.C):{e1.Equals(AnEnum.C)}"); // Try with a class AClass c1 = new AClass(){a = 1}; AClass c2 = new AClass(){a = 1}; Debug.WriteLine($"c1.Equals(c2):{c1.Equals(c2)}"); Debug.WriteLine($"c1.Equals(c1):{c1.Equals(c1)}"); Debug.WriteLine($"c1.Equals(null):{c1.Equals(null)}"); // Try with a struct AStruct s1 = new AStruct() { a = 1 }; AStruct s2 = new AStruct() { a = 2 }; //These go pop Debug.WriteLine($"s1.Equals(s1):{s1.Equals(s1)}"); //Debug.WriteLine($"s1.Equals(s2):{s1.Equals(s2)}"); //Debug.WriteLine($"s1.Equals(null):{s1.Equals(null)}"); //Debug.WriteLine($"s1.Equals(null):{s2.Equals(null)}"); //if ( s1!= null) { } Debug.WriteLine($"s1.a.Equals(s1):{s1.a.Equals(s1.a)}"); Debug.WriteLine($"s1.a.Equals(s1):{s1.a.Equals(s2.a)}"); } catch ( Exception ex) { Debug.WriteLine(ex.Message); } Thread.Sleep(Timeout.Infinite); } public enum AnEnum { A = 1, B = 2, C = 3 } public class AClass { public int a { get; set; } } public struct AStruct { public int a { get; set; } } } }