You are viewing a single comment's thread. Return to all comments →
string S = Console.ReadLine();
Console.WriteLine(S.Any(c=> !(c >= 48 && c <= 57) || c==' ')?"Bad String":S);
or
Console.WriteLine(Int32.TryParse(S, out int result)?result:"Bad String");
Seems like cookies are disabled on this browser, please enable them to open this website
Day 16: Exceptions - String to Integer
You are viewing a single comment's thread. Return to all comments →
string S = Console.ReadLine();
Console.WriteLine(S.Any(c=> !(c >= 48 && c <= 57) || c==' ')?"Bad String":S);
Console.WriteLine(Int32.TryParse(S, out int result)?result:"Bad String");