string str = "abc123"; string iResultTemp = string.Empty; string sCurrentVal = string.Empty; string sResult = string.Empty; for (int i = 0; i < str.Length; i++) { try { sCurrentVal = str.Substring(i, 1); if(IsNumeric(sCurrentVal)) { iResultTemp += sCurrentVal; } else { sResult += str.Substring(i, 1); } } catch { // Catch Exception } } int iFinalResult = int.Parse(iResultTemp); string sFinalResult = sResult;
public bool IsNumeric(string s) { try { Int32.Parse(s); } catch { return false; } return true; }
Hall of Fame Twitter Terms of Service Privacy Policy Contact Us Archives Tell A Friend