Strip Decimal and Zero Fill


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. using System;
  2. namespace StripDecimal_CS
  3. {
  4. class RemoveDecimal
  5. {
  6. static void Main(string[] args)
  7. {
  8. double testNum = 255.95;
  9. string noDecimalVal = testNum.ToString().Replace(".", "").PadLeft(9, '0');
  10.  
  11. Console.WriteLine("Original Value: " + testNum.ToString());
  12. Console.WriteLine("Value w/No Decimal: " + noDecimalVal);
  13. }
  14. }
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.