.net - Avoid Current Culture in ToString(..) -


i need format decimal value per display format specified. "decimalvalue.tostring("##,##,##,##,##,##,###")" in code below considering current application culture internally , formatting value accordingly.

i tried culutreinfo.invariantculture - didn't because "numberformat.currencygroupsizes" of invariantculture set 3 , considering while formatting value.

i need avoid it, should able tell application ingore culture , format value per displayformat specified.

any solution ? please help.

e.g.

 decimal? de = 1234567890;  string displayformat = "##,##,##,##,##,##,###";  string result = de.value.tostring(displayformat);  system.console.writeline(result);  

o/p - 1,234,567,890 (application culture en-us).

try this:

decimal? de = 1234567890; string displayformat = "##/##/##/##/##/##/###"; string result = de.value.tostring(displayformat).replace("/", ",").trimstart(new char[] { ',' } ); system.console.writeline(result);  

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -