Программирование - это просто
Advertisement
arrow arrow Visual C# arrow Visual C# . 9. . .
01.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
Visual C# . 9. . . E-mail
megabax   
12.01.2012 .
Delphi

Visual C# . 9. . .

. . : , :

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. :

Visual C#  .  9.  . .

, , , , . , . , :

            Console.Write(" 1 10 ");

            int x = int.Parse(Console.ReadLine());

            if (x < 1 || x > 10) throw new ArgumentOutOfRangeException(" 1 10!!! ");

            Console.ReadLine();

, , 1 10:

Visual C#  .  9.  . .

, , "", 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();

        }

    }

}

, :

Visual C#  .  9.  . .

 

 

()

 

( 27.05.2014 . )
 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .