Re: Converting string to double



SMichal wrote:
Hi, how can I parse string "? 20.000" to double ?


Well, you obviously need to remove the '?' character and space before
it can be parsed to any numerical format. So I would use the Split()
function to remove the '?' character and the Trim() function to remove
the space:

string strNumber = "? 20.000";
strNumber = strNumber.Split('?');
strNumber.Trim();

Then use the Convert.ToDouble() function to convert the string to a
double value:

double myVal = Convert.ToDouble(strNumber);

If the value you are converting should be represented as currency or
requires a certain degree of precision you should use the
String.Format() function after converting your value. I hope that helps.

.



Relevant Pages

  • Re: help needed on coversin of an char array to an integer
    ... Im kinda stuck in a project at a point where i need an array to ... Converting a character to it's numeric value is a ... '0' - '9' are contiguous in the character ... If you can guarantee that your character set has contiguous alphabetics ...
    (comp.lang.c)
  • Re: equal sign substituted for apostrophe
    ... apostrophe, instead of being the character from the default paragraph font, ... is a WP Typographic Symbols character. ... > One a couple of my workstations several word documents are converting an ... > apostrophe to an equal sign when the document is opened. ...
    (microsoft.public.word.application.errors)
  • Re: Binary byte in TCL gets pre-fixed by byte 0xC2, while accessing through C++ function via SWI
    ... I have a problem in converting a binary data into a character buffer ... % myObj WRAP_TestFn $t 1 ... You are creating a single character with value 0xB0. ... Are you trying to pass text to your C++ function or raw binary data? ...
    (comp.lang.tcl)
  • Re: 4th Edition Basic Set Supers
    ... 4th Ed. PC usually need higher CP totals for ... the same powers, compared to 3rd Ed. ... If you are converting a bunch of PC to 4th Ed., ... ed.) character. ...
    (rec.games.frp.gurps)
  • Re: need to convert a char to an hexadecmial value
    ... I needed help in converting a character to the correspoding ... only an insigificant amount of data space, ... Just use int. ... , to a newline character. ...
    (comp.lang.c)