Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.hackerrank.com/challenges/30-exceptions-string-to-integer/problem
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- class Solution {
- static void Main(String[] args) {
- string S = Console.ReadLine();
- int i = 0;
- try{
- i = int.Parse(S);
- Console.WriteLine(i);
- }
- catch(FormatException fe){
- Console.WriteLine("Bad String");
- }
- catch(Exception e){
- Console.WriteLine("Bad String");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement