public static int String2Int(String str) { int result = 0; try { if (str != null) { result = int.Parse(str); } } catch (Exception) { result = 0; } return result; } }