Custom classes, ToString, and format strings

Discussion in 'ASP .Net' started by Nathan Sokalski, Jun 8, 2008.

  1. I have a custom class, and I would like to overload the ToString method so
    that it accepts a format string like DateTime (and many other classes). I
    believe this involves implementing the IFormattable interface, but the stuff
    I found in the documentation showed it as accepting two parameters, the
    format string and a System.IFormatProvider (I only want it to accept the
    format string). Does anybody know of any good examples of doing this? I am
    using VB.NET 2.0, but if an example in VB.NET is unavailable I would
    appreciate an example in C# as well. Thanks.
     
    Nathan Sokalski, Jun 8, 2008
    #1
    1. Advertisements

  2. Cor Ligthert[MVP], Jun 9, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.