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.

Try something like this:

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

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)?

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

Thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.