Aggregated reflection-based ToString() implementation

Instead displaying your object’s public fields(properties) in ordinary way ,that doesn’t so informative

string foo = string.Format( "My name is {0} {1} and my birthday is {2:MM/dd/yyyy}", 
                            p.FirstName, p.LastName, p.BirthDate );

you can print your object using FormattableObject library

Person p = new Person( "Scott","Hanselman",new DateTime(1974,1,22) );
string foo = p.ToString("My name is {FirstName} {LastName} and my birthday is {Birthdate:MM/dd/yyyy}");

Download FormattableObject 0.5

[ Via ComputerZen.com ]


 
 
 

Leave a Reply