Search code examples
c#asp.netdecimal-point

How to break a decimal value into integral and decimal portions


I'm currently working on a hotel management system's invoice (asp.net c#)... My question is that how to show the round off on a label example if the total amount is 8023.25 round off label should show .25 and totallabel should show 8023... Please can anybody help me with this {with code} ???


Solution

  • You can split it and use them like:

    string s = inputValue.ToString("8023.25", CultureInfo.InvariantCulture);
    string[] parts = s.Split('.'); 
    int i1 = int.Parse(parts[0]);
    int i2 = int.Parse(parts[1]);