Exemple #1
0
        public static void QUESTIONALL177()
        {
            Class1a        a     = new Class1a(1, "AS");
            Class1a        b     = new Class1a(1, "AS");
            Class1a        c     = new Class1a(2, "AS");
            Class1a        d     = new Class1a(1, "ASA");
            Class1a        e     = new Class1a(3, "ASI");
            List <Class1a> lista = new List <Class1a>();

            lista.Add(a);
            lista.Add(b);
            lista.Add(c);
            lista.Add(d);
            lista.Add(e);
            //string result = "";
            if (lista is List <Class1a> )
            {
                Console.WriteLine("lista is List<Class1a>");
            }
            if (lista is List <Class1a>[])
            {
                Console.WriteLine("lista is List<Class1a>[]");
            }

            if (lista.GetType() is List <Class1a>[])
            {
                Console.WriteLine("lista.GetType() is List<Class1a>[]");
            }

            if (lista.GetType() is List <Class1a> )
            {
                Console.WriteLine("lista.GetType() is List<Class1a>");
            }
        }
Exemple #2
0
        public static void QUESTIONALL193()
        {
            Class1a a = new Class1a(1, "AS");
            Class1a b = new Class1a(1, "AS");

            Console.WriteLine(a.Equals(b));

            //Class1a c = new Class1a(2, "AS"); //inne id
            //Console.WriteLine(a.Equals(c));

            Class1a d = new Class1a(1, "ASA"); //inne name

            Console.WriteLine(a.Equals(d));

            //Class1a e = new Class1a(3, "ASI");//oba inne
            //Console.WriteLine(a.Equals(e));

            //Console.WriteLine(a.Equals(null));
            string a1 = "AS";
            string b1 = "AS";

            if (!a1.Equals(b1))
            {
                Console.WriteLine("Equals pokazało że rózne : if (!a1.Equals(b1))");
            }
            else
            {
                Console.WriteLine("Equals pokazalo ze takie same");
            }
            if (a1 != b1)
            {
                Console.WriteLine("a1!=b1 pokazało że rózne ");
            }
            else
            {
                Console.WriteLine("takie same");
            }
            if (!Object.Equals(a1, b1))
            {
                Console.WriteLine("Equals pokazało że rózne : !Object.Equals(a1,b1)");
            }
            else
            {
                Console.WriteLine("Equals pokazalo ze takie same");
            }
        }
Exemple #3
0
 public bool Equals(Class1a other)
 {
     if (other == null)
     {
         return(false);
     }
     if (this.ID != other.ID)
     {
         return(false);
     }
     //if (!this.Name.Equals(other.Name)) return false;
     if (!Object.Equals(this.Name, other.Name))
     {
         return(false);
     }
     return(true);
 }