Skip to content

Instantly share code, notes, and snippets.

@martinusso
Created May 5, 2014 19:18
Show Gist options
  • Save martinusso/173fb3f14a1ec3e8f0fa to your computer and use it in GitHub Desktop.
Save martinusso/173fb3f14a1ec3e8f0fa to your computer and use it in GitHub Desktop.
only numbers in C#
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