Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The optimal way to check if a query string is an int?

Tags:

c#

asp.net

A question that came to one of my colleagues mind, what is the best way to check if a query string is an int. I suggested using the classic Int.Parse and try and catch, also TryParse was suggested. Actually i can't think of any other ways. Any ideas?

like image 561
Galilyou Avatar asked Dec 03 '22 08:12

Galilyou


1 Answers

Int32.TryParse is going to be your best bet.

like image 117
Andrew Hare Avatar answered Dec 04 '22 22:12

Andrew Hare