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" 2 1543
Hi,
Why not try this.
dim n as integer = 123
System.Console.WriteLine(String.Format("{0:O}", n))
Ken
--------------------
"gjuro kladaric" <gj***@email.htnet.hr> wrote in message
news:eo**************@TK2MSFTNGP14.phx.gbl... 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"
hi, ken,
thanks for the answer
however, if I understand it well, your sample would not work, unless you
supply the format provider, like this:
dim n as integer = 123
System.Console.WriteLine(String.Format(format_prov ider, "{0:O}", n))
I am aware that I can do that, and also something like:
dim mc as myClass
mc.int_var = 123
System.Console.WriteLine(mc.int_var.ToStringOctal( ))
however, my question was if I can link my format provider (for octal
representation) into .NET runtime, so that my way of octal formatting of an
integer, for eaxmple, is available everywhere where traditional formatting
is available
do you know that answer?
thanks,
gjuro
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:Ox**************@TK2MSFTNGP09.phx.gbl... Hi,
Why not try this.
dim n as integer = 123 System.Console.WriteLine(String.Format("{0:O}", n))
Ken -------------------- "gjuro kladaric" <gj***@email.htnet.hr> wrote in message news:eo**************@TK2MSFTNGP14.phx.gbl... 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"
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sverre Bakke |
last post by:
Hi
I am using the base_convert() function to convert numbers between binary,
hexadecimal, decimal, etc... It works great, but I have problems converting
numbers with .'s
Like this number:
...
|
by: Rowan Chapman |
last post by:
Hey all!
I'm kinda new to VB but not to programin'.
So I know what it is like when you are asked trivial questions.
Could some1 please tell me what the syntax would be 2 only allow numerical
data...
|
by: Willem Broekema |
last post by:
To me, it seems there are some irregularities in how literal numbers are
interpreted.
As you know, Python allows integer literals in three bases:
"11" -> (decimal) 11
"011" -> octal 11 = 9...
|
by: Willem-Jan Selen |
last post by:
Hie everybody,
I have a problem with the following,
I have a table with a row containing numbers with 2 decimal places.
I want to count the sum of these numbers but my valuw returned is far...
|
by: siliconwafer |
last post by:
Hi All,
What does a 'format specifier' do?
Suppose I do,
int a = 43; //decimal number
printf("%x",a);
I will get hex equivalent of 43.
Does the format specifier do an implicit "decimal to hex"...
|
by: Stan |
last post by:
The convert method allows us to change any base number (bin, octal,
hex ) to decimal, but how can I change a decimal value back to an
octal number???
Thanks in advance
Stan
|
by: Duncan Winn |
last post by:
I have written an Ole Db provider. It seems to be registered in the
Operating system to a degree, but not fully, i.e. I can access it from a
client that I have written. But it does not appear in...
|
by: David Rysdam |
last post by:
I have a large amount of data that I copy in and out of Sybase very
often. Now I also want to copy this data in and out of postgres. I
have an existing script that creates the entire database(s)...
|
by: naunetr |
last post by:
in program below
#include <stdio.h>
int main()
{
int id = 123, io = 0123, ih = 0x123;
long ld = 1234567L, lo = 01234567l, lh = 0X1234567L;
float f = 123.456f;
double d = 01234.56789L;
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |