Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Rextester.Program.Main is the entry point for your code. Don't change it.
- //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Rextester
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- int x = 12;
- int y = 0;
- Console.WriteLine(divide(x, y)); //calles diveide methode and print return value
- }
- public static int divide(int x, int y) {
- int result = -1; //default value
- try { //try divideing
- result = x / y;
- } catch(Exception ex) { //call when error
- Console.WriteLine(ex.Message); //print error
- }
- return result; //return the value if -1 then error
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement