I'm a novice with C# and I've read a few other questions about decimals but still goes over my head , so I ask how do i 1) Change Average Inventory to english pounds as i have read questions but they all seem to be static ones where as mine are changing.
Average inventory = (Beginning inventory + Ending inventory) / 2.0
Turnover = Cost of goods sold / Average inventory
http://i42.tinypic.com/17bvpv.png
So All im trying to achieve is changing Average Inventory to currency a NO decimal places , possibly rounding. Changing TurnOver to 1 Decimal Place.
These are some codes i found but there meaning is beyond me
//decimal.Round = something.ToString("$#,2") ;
// Decimal.Round = resultDecimal = decimal.Round(amountDecimal, 2);
// decimal.Round(DecimalValue, Integer = .1);
//decimal.Round(1.25M, 1, MidpointRounding.AwayFromZero);
// double after1 = Math.Round(before1, 1, MidpointRounding.AwayFromZero);
// Math.Round(3.44, 1); //Returns 3.4.
//decimal.Round(1, MidpointRounding.AwayFromZero);
decimal d = 100000.123456M;
var s = d.ToString("C0", new CultureInfo("en-GB")); //gives £100,000
Where the C
indicated currency formatting and the 0
indicated the nr. of decimal places.
Try this:
using System.Globalization;
...
decimal d = 100000.123M;
NumberFormatInfo nfi = new CultureInfo("en-GB", false).NumberFormat;
nfi.CurrencyDecimalDigits = 0;
var s = d.ToString("C", nfi);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.