public static int ToInt(this string str, int defVal = 0) { int res; return int.TryParse(str, out res) ? res : defVal; }