Alternatives
Members may post updates or alternatives to this current article in order to show different
approaches or add new features.
Here with generics:public static string ToString(this T obj, Func toStringFunction) { return toStringFunction(obj); }You can use it like this:Console.WriteLine(person.ToString(p=>p.Name));
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...
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.