Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Person1 p = new Person1("John", "Doe");

            Console.WriteLine("Person1: ");
            Console.WriteLine(string.Format("No format: {0}", p.ToString()));
            Console.WriteLine(string.Format("FL format: {0}", p.ToString("FL")));
            Console.WriteLine(string.Format("LF format: {0}", p.ToString("LF")));
            Console.WriteLine(string.Format("FSL format: {0}", p.ToString("FSL")));
            Console.WriteLine(string.Format("LSF format: {0}", p.ToString("LSF")));

            Console.WriteLine();
            Console.WriteLine("Person2: ");
            Person2 p2 = new Person2("John", "Doe");

            Console.WriteLine(string.Format("No format: {0}", p2.ToString()));
            Console.WriteLine(string.Format("FL format: {0}", p2.ToString("FL")));
            Console.WriteLine(string.Format("LF format: {0}", p2.ToString("LF")));
            Console.WriteLine(string.Format("FSL format: {0}", p2.ToString("FSL")));
            Console.WriteLine(string.Format("LSF format: {0}", p2.ToString("LSF")));

            Console.Write("Press a key to exit");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Person1 p = new Person1("John", "Doe");
            Console.WriteLine("Person1: ");
            Console.WriteLine(string.Format("No format: {0}", p.ToString()));
            Console.WriteLine(string.Format("FL format: {0}", p.ToString("FL")));
            Console.WriteLine(string.Format("LF format: {0}", p.ToString("LF")));
            Console.WriteLine(string.Format("FSL format: {0}", p.ToString("FSL")));
            Console.WriteLine(string.Format("LSF format: {0}", p.ToString("LSF")));

            Console.WriteLine();
            Console.WriteLine("Person2: ");
            Person2 p2 = new Person2("John", "Doe");
            Console.WriteLine(string.Format("No format: {0}", p2.ToString()));
            Console.WriteLine(string.Format("FL format: {0}", p2.ToString("FL")));
            Console.WriteLine(string.Format("LF format: {0}", p2.ToString("LF")));
            Console.WriteLine(string.Format("FSL format: {0}", p2.ToString("FSL")));
            Console.WriteLine(string.Format("LSF format: {0}", p2.ToString("LSF")));

            Console.Write("Press a key to exit");
            Console.ReadKey();
        }