static void Main(string[] args) { Program pg = new Program(); DividResult result = pg.Divide(50, 0); Console.WriteLine(result.Success + ": " + result.Result); result = pg.Divide(50, 10); Console.WriteLine(result.Success + ": " + result.Result); }
DividResult Divide(int n1, int n2) { DividResult ret = new DividResult(); if (n2 == 0) { ret.Success = false; return(ret); } ret.Success = true; ret.Result = n1 / n2; return(ret); }