Click here to Skip to main content
15,893,508 members
Articles / Programming Languages / C#

Useful wrapper class to override the Object.ToString method

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
4 Oct 2011CPOL 6.6K  
You can write an extension method like this:public static class ToStringExtensionMethod{ public static string ToString(this Person person, bool showName) { return person.Name; }}then you can use it like this:public class Program{ Person person = new...

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions