Created
March 20, 2010 03:09
-
-
Save rtipton/338446 to your computer and use it in GitHub Desktop.
C# -- Strip Decimal & Zero Fill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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