Wednesday 3 January 2018

Exceptions Handling Program in C#(Sharp)

                 Exceptions Handling Program in C#(Sharp)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TrappedExceptions
{
    class Program
    {
        
        static void Main(string[] args)
        {
            //  Exceptions  trapped Program
           try{ // using try... catch 
                
                int first, second;
                Console.Write("Enter the first number=>");
                first = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter the second number=>");
                second = Convert.ToInt32(Console.ReadLine());
                int  result =  first/second;
                Console.WriteLine(result);
                Console.ReadLine();
             }catch(Exception) 
               {
                Console.WriteLine("Divide by Zero error");// if value is Divide by Zero.
                Console.ReadLine();
               }
        }
     }
  }

No comments:

Post a Comment

😍Developer on Weekends #shorts #officememes #developermemes

😍Developer on Weekends #shorts #officememes #developermemes Welcome to the latest viral YouTube shorts meme for developers! 😍Developer on...