As you have only tagges your question to C#, I am not sure if you want to do this in Windows or Web App.
In any case, I would use the regular expressions.
For start, you can use the following RegEx.
Regex regex = new Regex("^[0-9]+$");
Read more about the
Regex [
^]class on MSDN.