Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using This in a method call
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00721707
Message ID:
00721911
Vues:
12
What is actually going on is the writeline method is calling the ToString method of the class. If you look at the online help, you will see how it references the implicit call to ToString. This is confusing and for readability, I would recommend expicitly calling ToString.

>I have been learning C# thru Deitel's C# book. They have an example that they don't clearly explain the reason for the result.
>
>In a contructor for a class they have:
>
>writeline("Circle 5 constructor: {0}", this );
>
>
>They explain that "this" implicitly calls the ToString() method of the class. How does the class know that ToString() is the method to call. There are 3 methods in the class. In looking at it, only one class returns a string. Could that be the reason?
>
>Thanks,
>
>Perry
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform