Identify if a string is a number
Identify if a string is a number
Identify if a string is a number
Re: Identify if a string is a number
```
int n;
bool isNumeric = int.TryParse("123", out n);
```
**Update** As of C# 7:
```
var isNumeric = int.TryParse("123", out int n);
```
or if you don't need the number you can [discard](https://learn.microsoft.com/en-us/dotnet/csharp/discards) the out parameter
```
var isNumeric = int.TryParse("123", out _);
```
The *var* s can be replaced by their respective types!
int n;
bool isNumeric = int.TryParse("123", out n);
```
**Update** As of C# 7:
```
var isNumeric = int.TryParse("123", out int n);
```
or if you don't need the number you can [discard](https://learn.microsoft.com/en-us/dotnet/csharp/discards) the out parameter
```
var isNumeric = int.TryParse("123", out _);
```
The *var* s can be replaced by their respective types!