Does anyone know of a money type in .NET?

前端 未结 3 1592
忘了有多久
忘了有多久 2020-12-16 11:46

Does anyone know of an already implemented money type for the .NET framework that supports i18n (currencies, formatting, etc)? I have been looking for a well implemented typ

3条回答
  •  -上瘾入骨i
    2020-12-16 12:36

    I think you want to use the decimal data type, and use the appropriate overload for ToString().

    CultureInfo current  = CultureInfo.CurrentCulture;
    decimal myMoney = 99.99m;
    
    //formats as money in current culture, like $99.99
    string formattedMoney = myMoney.ToString("C", current); 
    

提交回复
热议问题