0

Hello!

I´m receiving in one text.box some values from external software.

The kind of value can be something like this:
0.234
2.345
23.45
234.5
2345.6
23456.7
etc...

I need to round and have only 1 decimal value.
If I use:

decimal x;
     x = decimal.Parse(original.Text);
     arredond.Text = Math.Round(x,0).ToString();

This function take out de "." and group all values, e.g. 2.345 -> 2345, etc.. and dont 2.3

But if I use 2,345 this works -> gives me the value = 2,3.

My result always come to c# app with "."

How can I change to "," or another way to solve this problem.

Thanks a lot.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by chromatinpt
0

Try something like this:

string text = "2.234";
            string strToParse = text.Replace('.', ','); //replace point with comma
            decimal x = decimal.Parse(strToParse);
0

Can you clarify, when you say you need 1 decimal number, do you mean you want a whole number (no '.' and no decimal value) or do you mean you wnat a number with 1 number after the '.' (a decimal with one significant figure)?

0

Hello Ryshad, with a significant figure like 1.5 or 1.8 etc.

Thanks a lot!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.