i'm a new in C#. I got a problem like this.
I want to obtain any selected item on ListBox. Those ListBox contain numerical value for example 5 , 10 , 12.5 , 30 ......
The problem appear when i want to convert the 12.5 into double, i alwayas got 125.0 not 12.5 it seLf. Here my code to obtain the value from the ListBox
arr variabel is an ArrayList.
|
JohanPosted Oct 7, 2010, 1:27 AM
i still got no luck with it.
i cannot use comma as the separator for it.
Gomathi PalaniswamyPosted Oct 6, 2010, 3:35 AM
try like this
string s = "100";
double d = Double.parse(s);
s = d.ToString("0.00");
Roy SPosted Oct 5, 2010, 2:35 PM
Hirendra SisodiyaPosted Oct 5, 2010, 9:28 AM
we can use 'parse' and 'convert' method for doing it, but you are still in problem after doing same things so please check itemChecked.ToString() value .
thanks
Rakesh JhaPosted Oct 5, 2010, 8:04 AM
Suthish NairPosted Oct 5, 2010, 4:06 AM
JohanPosted Oct 5, 2010, 3:46 AM
the 12.5 still become 125.0 not 12.5 in double format.
is there any other way ?
thx.
Suthish NairPosted Oct 5, 2010, 2:19 AM
Another way,
double value = double.Parse(itemChecked.ToString());
arr.Add(value);
Deepthi AravindPosted Oct 5, 2010, 12:51 AM
Which control you are using??
Rakesh JhaPosted Oct 5, 2010, 12:40 AM
foreach (object itemChecked in listBox1.SelectedItems)
{
arr.Add(Convert.ToDouble(itemChecked.ToString()));
}