The IFormatProvider and ICustomFormatter interfaces will provide you with the methods required to create your own formats.

The IFormatProvider requires you to implement one method: GetFormat which returns the object that provides the custom formatting. This is even implied by the name of the interface: “format” and “provider”. It generally returns an object that implements the ICustomFormatter interface.

Let’s say you’d like to capitalise all characters in a string. You can of course use the ToUpper() method but this is an easy entry point into this exercise. Here comes our IFormatProvider object:

New version: I’M TOO LAZY TO CAPITALISE THESE LETTERS., HELLO, GOOD BYE

What if you’d like to denote the capitalisation formatting in a special way and not apply it to all params elements automatically? You can use the “:” operator inside the placeholders much the same way as :C or :yyyy are used in the above examples from MSDN: