コード例 #1
0
ファイル: Program.cs プロジェクト: al-main/Asp-Dot-Net-CSharp
        /*
         * The default implementation of .ToString() method provided by System.Object class
         *      will give you the complete name of the type including the namespace.
         */
        static void Main(string[] args)
        {
            Customer c1 = new Customer();
            c1.FirstName = "Anand Dev";
            c1.LastName = "Singh";
            Console.WriteLine("Without override .ToString() method -> {0}",c1.ToString()); // It will print complete name of the type including the namespace.

            CustomerWithOverriddenToString c2 = new CustomerWithOverriddenToString();
            c2.FirstName = "Anand Dev";
            c2.LastName = "Singh";
            Console.WriteLine("\nAfter override .ToString() method -> {0}",c2.ToString());

            Console.ReadKey();
        }
コード例 #2
0
        /*
         * The default implementation of .ToString() method provided by System.Object class
         *      will give you the complete name of the type including the namespace.
         */
        static void Main(string[] args)
        {
            Customer c1 = new Customer();

            c1.FirstName = "Anand Dev";
            c1.LastName  = "Singh";
            Console.WriteLine("Without override .ToString() method -> {0}", c1.ToString()); // It will print complete name of the type including the namespace.

            CustomerWithOverriddenToString c2 = new CustomerWithOverriddenToString();

            c2.FirstName = "Anand Dev";
            c2.LastName  = "Singh";
            Console.WriteLine("\nAfter override .ToString() method -> {0}", c2.ToString());

            Console.ReadKey();
        }