Created
May 5, 2014 19:18
-
-
Save martinusso/173fb3f14a1ec3e8f0fa to your computer and use it in GitHub Desktop.
only numbers in C#
This file contains hidden or 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
class OnlyNumbers | |
{ | |
private string value; | |
public OnlyNumbers(string value) | |
{ | |
this.value = value; | |
} | |
public override string ToString() | |
{ | |
string onlyNumber = ""; | |
foreach (char s in this.value) | |
{ | |
if (Char.IsDigit(s)) | |
{ | |
onlyNumber += s; | |
} | |
} | |
return onlyNumber; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment