Custom classes, ToString, and format strings

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

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.
 
Back
Top