P
PIEBALD
I'm working on a utility that will allow the user to query some data from a
database and output it.
I would like to support allowing the user to provide a format for the
numbers, particularly if hexadecimal representation is desired.
Ideally I could simply do ((System.IFormattable) datarow [ columnname
]).ToString ( format , null ), but when hexadecimal is requested the user may
(should) want to tack on a leading "0x" and I've been unable to form a format
that will do that.
What should work is "'0x'X4", the '0x' should be copied to the output and
then the value should be formatted with X4. But, that doesn't seem to work,
even though the documentation seems to say it should.
The closest I've gotten is string.Format ( format , datarow [ columnname ] )
with a format of "0x{0:X4}", but the user shouldn't need to specify the
braces and such.
Am I mistaken that "'0x'X4" should work? Or is it a bug?
database and output it.
I would like to support allowing the user to provide a format for the
numbers, particularly if hexadecimal representation is desired.
Ideally I could simply do ((System.IFormattable) datarow [ columnname
]).ToString ( format , null ), but when hexadecimal is requested the user may
(should) want to tack on a leading "0x" and I've been unable to form a format
that will do that.
What should work is "'0x'X4", the '0x' should be copied to the output and
then the value should be formatted with X4. But, that doesn't seem to work,
even though the documentation seems to say it should.
The closest I've gotten is string.Format ( format , datarow [ columnname ] )
with a format of "0x{0:X4}", but the user shouldn't need to specify the
braces and such.
Am I mistaken that "'0x'X4" should work? Or is it a bug?