Is there any function like that?
Char.IsNumber() definitely does not work.
Thank you.
:: bool Char.IsHex(char c)
::
:: Is there any function like that?
::
:: Char.IsNumber() definitely does not work.
::
:: Thank you.
Not aware of one, but it would be a pretty easy function to write...
--
Regards,
Chris.
(Remove Elvis's shoes to email me)
>In message gifos2tdu64nca3ku...@4ax.com,
>Tremendo <nom...@hatespam.com> Proclaimed from the tallest tower:
>
>:: bool Char.IsHex(char c)
>::
>:: Is there any function like that?
>::
>:: Char.IsNumber() definitely does not work.
>::
>:: Thank you.
>
>Not aware of one, but it would be a pretty easy function to write...
Sure, but I am amazed that, among the hundreds of functions that the framework includes, they forgot
to include one so useful as that.
BTW, is there anything shorter than this?
if (Char.IsDigit(c) || ((Char.ToLower(c) >='a') && (Char.ToLower(c) <='f')))
...
I mean, is there any function like this?
bool Char.InSet(char c,string set_of_case_insensitive_characters)
that I could call like this
if (Char.InSet(c,"0123456789ABCDEF"))
...
Thanks
this should work.
Cheers,
Fabrizio
"Tremendo" <nom...@hatespam.com> wrote in message
news:ahgos2tltqvpoke89...@4ax.com...
bool System.Uri.IsHexDigit(char) would seem to be what you want.
rossum
if ("0123456789ABCDEF".IndexOf(c) >= 0)...
JR
"Luc E. Mistiaen" <luc.mi...@advalvas.be.no.spam> wrote in message
news:%23gdqBQG...@TK2MSFTNGP02.phx.gbl...
/LM
"JR" <NoM...@qsm.co.il> wrote in message
news:uGuA90IT...@TK2MSFTNGP06.phx.gbl...
2. Although these days cycles to not matter much, converting the character
to uppercase is an expensive operation, locale dependent, and in this simple
case I think it would be better to add the lowercase letters to the string.
JR
"Luc E. Mistiaen" <luc.mi...@advalvas.be.no.spam> wrote in message
news:OEP%23dzMTH...@TK2MSFTNGP05.phx.gbl...
Converting to lowercase is locale dependent as well. Personally I'd
just use
return (x >= '0' && x <= '9') ||
(x >= 'a' && x <= 'f') ||
(x >= 'A' && x <= 'F');
Simple and effective.
--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too