N
N
NeoLight22022-03-17 19:38:01
C++ / C#
NeoLight2, 2022-03-17 19:38:01

When translating a float into a string, the number is obtained with a comma, not a dot. Is it possible to convert float to string so that the number is with a dot?

I work with SQL in C#.
When trying to insert a row with float values ​​from C#, the error "Data trunsducted for row x1" is thrown.
As I understand it, this error only comes out because my C# program sends a request with the number 32523.425 instead of the number 32523.425 , because C# puts a comma instead of a period.
The question is, is it possible to somehow convert a float to a string so that the number is with a dot, and not with a comma?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-03-17
@NeoLight2

The comma is written due to the fact that you have Russian culture.
You can pass the necessary culture in ToString.
For example:

(42.5).ToString(System.Globalization.CultureInfo.InvariantCulture)


When trying to insert a string with float types from C#, an error occurs

Make parameterized queries so that this doesn't happen.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question