I
I
ikutin6662021-10-13 19:09:06
C++ / C#
ikutin666, 2021-10-13 19:09:06

How does ToString() work?

ToString() method of Object, how is it that ToString() knows about the child class and outputs its name? and even if I bring it to object the behavior does not change?

public class TEST
    { 
    }
Console.WriteLine(test.ToString()); //TEST.Program+TEST
Console.WriteLine((object)test.ToString()); //TEST.Program+TEST

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2021-10-13
@ikutin666

The answer to your question is here Object.ToString Method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question