예제 #1
0
        static void Main(string[] args)
        {
            ABC var_abc = new ABC(100);
            DEF var_def = new DEF(100);

            Console.WriteLine(var_abc.a);
            Console.WriteLine(var_def.a);

            Console.WriteLine("--------------- Using Methods ----------------------------");

            var_abc.add_one();
            var_def.add_one();
            Console.WriteLine(var_abc.a);
            Console.WriteLine(var_def.a);

            Console.WriteLine("--------------- Using Static Functions ----------------------------");

            add_one( var_abc );
            add_one(var_def);
            Console.WriteLine(var_abc.a);
            Console.WriteLine(var_def.a);

            Console.Read();
        }
예제 #2
0
        static void Main(string[] args)
        {
            ABC var_abc = new ABC(100);
            DEF var_def = new DEF(100);

            Console.WriteLine(var_abc.a);
            Console.WriteLine(var_def.a);

            Console.WriteLine("--------------- Using Methods ----------------------------");

            var_abc.add_one();
            var_def.add_one();
            Console.WriteLine(var_abc.a);
            Console.WriteLine(var_def.a);

            Console.WriteLine("--------------- Using Static Functions ----------------------------");

            add_one(var_abc);
            add_one(var_def);
            Console.WriteLine(var_abc.a);
            Console.WriteLine(var_def.a);

            Console.Read();
        }
예제 #3
0
 private static void add_one(ABC var_abc)
 {
     var_abc.add_one();
 }
예제 #4
0
        /// <summary>
        /// Just a chance to play with the various equality operations
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ABC abc_1 = new ABC(1);
            Object disquised_string_1 = "happy";
            string string_1 = "happy";
            ABC abc_2 = new ABC(2);
            Object disquised_abc_1 = new ABC(1);
            Object disquised_abc_2 = new ABC(2);
            int count = 0;

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if ( disquised_string_1.Equals(string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if ( string_1.Equals(disquised_string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if ( abc_1.Equals(disquised_string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if ( abc_1.Equals(string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (disquised_string_1.Equals(string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (abc_1 == abc_2)
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if ( disquised_abc_1 == disquised_abc_2 )
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if ( disquised_abc_1.Equals(disquised_abc_2))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (abc_1 == disquised_abc_1)
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (disquised_abc_1 == abc_1 )
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            ABC abc_3 = 4;
            if (abc_3 == new ABC(4))
            {
                Console.WriteLine("yes the implicit cast worked");
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            ABC abc_4 = "hello";
            ABC abc_5 = 10;
            if (abc_4 == abc_5)
            {
                Console.WriteLine("yes the string cast works");
            }



            Console.Read();
        }
예제 #5
0
 private static void add_one(ABC var_abc)
 {
     var_abc.add_one();
 }
예제 #6
0
        /// <summary>
        /// Just a chance to play with the various equality operations
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ABC    abc_1 = new ABC(1);
            Object disquised_string_1 = "happy";
            string string_1           = "happy";
            ABC    abc_2           = new ABC(2);
            Object disquised_abc_1 = new ABC(1);
            Object disquised_abc_2 = new ABC(2);
            int    count           = 0;

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (disquised_string_1.Equals(string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (string_1.Equals(disquised_string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (abc_1.Equals(disquised_string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (abc_1.Equals(string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (disquised_string_1.Equals(string_1))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (abc_1 == abc_2)
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (disquised_abc_1 == disquised_abc_2)
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (disquised_abc_1.Equals(disquised_abc_2))
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (abc_1 == disquised_abc_1)
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            if (disquised_abc_1 == abc_1)
            {
                Console.WriteLine("yes " + count);
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            ABC abc_3 = 4;

            if (abc_3 == new ABC(4))
            {
                Console.WriteLine("yes the implicit cast worked");
            }

            Console.WriteLine("--- " + count++ + " --------------------------------------------------");
            ABC abc_4 = "hello";
            ABC abc_5 = 10;

            if (abc_4 == abc_5)
            {
                Console.WriteLine("yes the string cast works");
            }



            Console.Read();
        }