Hi makumbi,
You can't convert the number with special character to integer using Integer.TryParse is not possible.
You can handle the error using the below way.
C#
int customerId = 0;
string value = "05-07152";
bool success = int.TryParse(value, out customerId);
if (success)
{
Response.Write(String.Format("Converted <b>{0}</b> to <b>{1}</b>.", value, customerId));
}
else
{
Response.Write(String.Format("Conversion of <b>{0}</b> to int failed.", value));
}
VB.Net
Dim customerId As Integer = 0
Dim value As String = "05-07152"
Dim success As Boolean = Integer.TryParse(value, customerId)
If success Then
Response.Write(String.Format("Converted <b>{0}</b> to <b>{1}</b>.", value, customerId))
Else
Response.Write(String.Format("Conversion of <b>{0}</b> to int failed.", value))
End If