The generic type, which is inherited from the System.Object class, by default, the ToString method of the object class returns a string representation of the type of the current class. But there are exceptions!!
datetime, which overrides the ToString method, the ToString method of an instance of a DateTime type returns a string representation of a date, rather than a string representation of a DateTime type.
Another use case is that when we have a student class, we use Console.WriteLine (student), which will output "namespaces." Student ". This is what we don't want, we want to show the student's name when we export, then we need to rewrite the ToString method.
Public override String ToString ()
reutrn "Zhang San";
In this way, the result of the output will be the form of the student name you want.
C#... When do I need to rewrite the ToString () method?