megabax
|
12.01.2012 . |
Delphi
Visual C# . 9. .
.
.
.
: ,
:

(
) ,
main:
static void
Main(string[] args)
{
try
{
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);
}
catch(Exception
ex)
{
Console.WriteLine("
"+ex.GetType().Name+"
"+ex.Message);
}
Console.ReadLine();
} |
,
try ... catch.
:

, ,
, , . ,
.
,
:
Console.Write("
1 10 ");
int
x = int.Parse(Console.ReadLine());
if (x < 1 || x > 10)
throw new
ArgumentOutOfRangeException("
1
10!!!
");
Console.ReadLine(); |
,
, 1 10:

,
, "",
try ... catch:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
ConsoleApplication1
{
class Program
{
static void
Proba()
{
Console.Write("
1 10 ");
int
x = int.Parse(Console.ReadLine());
if (x < 1 || x > 10)
throw new
ArgumentOutOfRangeException("
1
10!!! ");
}
static void
Main(string[] args)
{
try
{
Proba();
}
catch (ArgumentOutOfRangeException
e)
{
Console.Write(" : "+e.Message);
}
Console.ReadLine();
}
}
} |
,
:

()
|
( 27.05.2014 . )
|