Custom classes, ToString, and format strings

  • Thread starter Nathan Sokalski
  • 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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top