c# - How to display output in the same culture that was entered using "double.Parse(str, CultureInfo.InvariantCulture);"? -


i'm pretty new c#, .net , programming on windows in general. here code:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.globalization;  namespace myapp {     class program     {         static void main(string[] args)         {             string linebreak = "\r\n";             string str = console.readline();             double number = double.parse(str, cultureinfo.invariantculture);             console.writeline("you've entered: " + number + linebreak + "variable type:" +number.gettype());             console.writeline("press key exit . . .");             console.read();         }     } } 

if enter double "32,45" (notice there comma separator), output this:

you've entered: 32,45 variable type: system.double 

but when enter double variable "32.45" (notice, there dot instead of comma), output this:

you've entered: 32,45 variable type: system.double 

it's same. know because of cultureinfo set on local machine.

how can make kind of independent(not changing settings or stuff, in code? when user opens program, shouldn't change in settings)?

like when type dot outputs double dots , when type comma displays comma?

best regards, pāvels.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -