C#: Default ToString method

This entry is part 60 of 71 in the series C#

In the previous post, we have overriden the default ToString method.

Here we show the default implementation of the ToString method. It returns the fully qualified name of the type of the Object.

using System;

namespace StringDisplay
    class Employee
        public string Name { get; set; }

        public int Age { get; set; }

    class Program
        static void Main(string[] args)
            string str;

            Employee e1 = new Employee();

            str = e1.ToString();

The output from running the above code will be StringDisplay.Employee.





Series Navigation<< C#: Overriding a built-in method ToString
C#: Generic method >>