Karolis Semaška
Karolis Semaška

Reputation: 41

Get object reference name as string c#

here`s a simple question:

I have something like this

       Youtube youtubeChannel = new Youtube();

       Console.WriteLine("youtubeChannel");

Instead hardcoding youtubeChannel in console, i want to get reference name as string and print it in console. Something like:

       Console.WriteLine(youtubeChannel.ToString());

And get result -> "youtubeChannel" in console.

Upvotes: 0

Views: 2489

Answers (1)

syntax error
syntax error

Reputation: 149

You can check how it was done here and take note of the pitfalls too..

Upvotes: 1

Related Questions