Microsoft interview question

convert strings into int types;

Interview Answers

Anonymous

19 Apr 2012

public ConvertStringToInt() { string s = "12345"; int n = 0; for (int i = 0; i < s.Length; i++) n = n * 10 + s[i] - '0'; }

2

Anonymous

19 Sept 2012

return(Convert.ToInt32(str))