I have a problem with the negetive sign. When I run the program in the development environment, in mathematical calculations, negative numbers are shown with a hyphen sign (‐), but when I publish the program and place it on IIS, negative numbers are shown with a minus sign (−) instead of hyphen (‐) sign.As a result, C# gets an error in converting to double type. Where does this problem come from?
i use c# and vscode for development, and the IIS(v.10) is also on the 2019 server
minus sign (−)
hyphen sign (‐)
NumberFormatInfo
allows you to set specific formatting for
display. It is highly related to Globalization
& Culture
:
https://learn.microsoft.com/en-us/dotnet/api/system.globalization.numberformatinfo?view=net-7.0
What you are looking for is the „NegativeSign“ property, where you should assign your application explicitly a new NFI instance to fix the issue.
In your case, the likely reason is some sort of localization mismatch where the system uses implicitly NFI Culture 1 in Development and in Production implicitly NFI Culture 2:
E.g. you develop on a machine that has its system setup to be in German and then deploy on a server that is setup in English. In this specific language example -to illustrate this to you- the usual error is a mix up between decimal separators e.g. 1.000,00 (DE) and 1,000.00 (EN). It very likely is down the same ally with your negative sign issue.