|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Apr 2009
Città: Aci Catena (CT)
Messaggi: 1021
|
[C#] String format: qualche dubbio!
Salve a tutti,
ho un problema con l'utilizzo di toString(format). Nell'applicazione l'utente può scegliere il numero di decimali da visualizzare, chiameremo la variabile numberOfDecimal. Ad ogni numero applico: Codice:
Decimal.Round(Convert.ToDecimal(myNumber), numberOfDecimal) Codice:
Decimal.Round(Convert.ToDecimal(myNumber), numberOfDecimal).ToString("#,#0.##")
Grazie. |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Apr 2009
Città: Aci Catena (CT)
Messaggi: 1021
|
Ho trovato questa soluzione e sembra funzionare:
Codice:
//Per la formattazione del numero
NumberFormatInfo numFormat = new NumberFormatInfo();
numFormat.NumberDecimalSeparator = ",";
numFormat.NumberGroupSeparator = ".";
Decimal.Round(Convert.ToDecimal(myNumber), numberOfDecimal).ToString("n", numFormat)
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 00:06.



















