Skip to content

Instantly share code, notes, and snippets.

@rtipton
Created March 20, 2010 03:09
Show Gist options
  • Save rtipton/338446 to your computer and use it in GitHub Desktop.
Save rtipton/338446 to your computer and use it in GitHub Desktop.
C# -- Strip Decimal & Zero Fill
using System;
namespace StripDecimal_CS
{
class RemoveDecimal
{
static void Main(string[] args)
{
double testNum = 255.95;
string noDecimalVal = testNum.ToString().Replace(".", "").PadLeft(9, '0');
Console.WriteLine("Original Value: " + testNum.ToString());
Console.WriteLine("Value w/No Decimal: " + noDecimalVal);
}
}
}
Imports System
Namespace StripDecimal_VB
Class RemoveDecimal
Shared Sub Main(ByVal args As String())
Dim testNum As Double = 255.95
Dim noDecimalVal As String = testNum.ToString().Replace(".", "").PadLeft(9, "0"c)
Console.WriteLine("Original Value: " + testNum.ToString())
Console.WriteLine("Value w/No Decimal: " + noDecimalVal)
End Sub
End Class
End Namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment