Delphi
Visual C# . 8.
(try,catch,exception)
. ,
- ,
. ,
. . -
,
. ,
. - .
. , ,
, . ,
, ,
.
.
C# , .
( ),
. "" .
-
. C#
, .
(
):
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
ConsoleApplication1
{
class Program
{
static void
M1(int x, int
y, int z)
{
try
{
int a =
checked((int)Math.Pow(x,
y));
Console.WriteLine("x
^ y / z = {0}", a / z);
}
catch (DivideByZeroException)
{
Console.WriteLine("
");
}
Console.WriteLine("M1
-
");
}
static void
M2(int x, int
y, int z)
{
try
{
M1(x, y, z);
}
catch (ArithmeticException)
{
Console.WriteLine("
");
}
Console.WriteLine("M2
-
");
}
static void
Main(string[] args)
{
Console.Write("x=");
int x =
int.Parse(Console.ReadLine());
Console.Write("y=");
int y =
int.Parse(Console.ReadLine());
Console.Write("z=");
int z =
int.Parse(Console.ReadLine());
M2(x, y, z);
Console.ReadLine();
}
}
} |
x, y z,
xy/z

, z
0? ,
:

:
try
{
int a =
checked((int)Math.Pow(x,
y));
Console.WriteLine("x
^ y / z = {0}", a / z);
}
catch (DivideByZeroException)
{
Console.WriteLine("
");
} |
:

catch,
. ,
, ,
.
catch
. ,
DivideByZero.
.
. ,
, M1 -
,
M2
try
{
M1(x, y, z);
}
catch (ArithmeticException)
{
Console.WriteLine("
");
}
|
:

, *,
"Microsoft Visual Studio 2010 Professional",
Microsoft..
()
|