c# - Format currency with symbol before instead of after -


i use converter textbox currency. works great, except €-sign after value instead of before.

here code:

public object convert(object value, type targettype, object parameter, cultureinfo culture) {     var dvalue = value decimal?;     return string.format(cultureinfo.getcultureinfo("de-de"), "{0:c}", dvalue ?? 0); } 

i know can put before instead of after so:

public object convert(object value, type targettype, object parameter, cultureinfo culture) {     var dvalue = value decimal?;     return "€ " + string.format(cultureinfo.getcultureinfo("de-de"), "{0:c}", dvalue ?? 0).replace("€", "").trim(); } 

but i'm assuming here there should standard in formatter this. so, know how put currency before value instead of behind using formatter itself?

for example: decimal 12345678.90, don't want display [see first method] 12.345.678,90 €, want display [see second method] € 12.345.678,90 instead.

try in way

public object convert(object value, type targettype, object parameter, cultureinfo culture) {     var dvalue = value decimal?;     thread.currentthread.currentculture = new cultureinfo("de");     var nfi = (numberformatinfo)numberformatinfo.currentinfo.clone();     nfi.currencysymbol = "€";     return string.format(nfi,"{0:c}",dvalue) } 

if doesn't work try without line

thread.currentthread.currentculture = new cultureinfo("de"); 

if doesn't work again try changing currencynegativepattern property , currencypositivepattern property value of 2

nfi.numberformat.currencypositivepattern = 2; nfi.numberformat.currencynegativepattern = 2; 

2 means "€ + number"


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -