G
gjuro kladaric
hi there,
I am just learning about IFormattable, ICustomFormatter, IFormatProvider and
the like...
although being a bit tricky to understand, it becomes clear after some
clicking and readying...
what is not clear to me and constitutes my question is:
I can build 'format provider' and use it with .ToString() and .Format()
methods. However, Console.WriteLine() does not allow for any 'format
provider'. Can I somehow 'create/register/hack/build' a format provider into
the runtime system (for the lifetime of my application or forever), for (for
example) applicationwide or systemwide formatting numbers as octal, so I can
use transparently the following statement:
dim n as integer = 123
System.Console.WriteLine("{0:O}", n)
which would produce "173"
or
dim n as integer = 123
System.Console.WriteLine("{0:NumberToWordsFormat}", n)
which would produce "one hundred twenty three"
I am just learning about IFormattable, ICustomFormatter, IFormatProvider and
the like...
although being a bit tricky to understand, it becomes clear after some
clicking and readying...
what is not clear to me and constitutes my question is:
I can build 'format provider' and use it with .ToString() and .Format()
methods. However, Console.WriteLine() does not allow for any 'format
provider'. Can I somehow 'create/register/hack/build' a format provider into
the runtime system (for the lifetime of my application or forever), for (for
example) applicationwide or systemwide formatting numbers as octal, so I can
use transparently the following statement:
dim n as integer = 123
System.Console.WriteLine("{0:O}", n)
which would produce "173"
or
dim n as integer = 123
System.Console.WriteLine("{0:NumberToWordsFormat}", n)
which would produce "one hundred twenty three"