A Smarter (or Pure Evil) ToString with Extension Methods

May 1, 2008 12:18 by admin

Scott Hanselman is at it again with a smarter and possibly evil ToString extension method.  Here is his example usage:

public void MakeSimplePersonFormattedStringWithDoubleFormatted()
{
    Person p = new Person();
    string foo = p.ToString("{Money:C} {LastName}, {ScottName} {BirthDate}");
    Assert.AreEqual("$3.43 Hanselman, {ScottName} 1/22/1974 12:00:00 AM", foo);
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

January 6. 2009 20:05