P
P
PlaBetaVer2020-09-06 12:28:35
C++ / C#
PlaBetaVer, 2020-09-06 12:28:35

Is it good to use a separate method for input?

I want to write code normally, and not to code, is it worth doing input through methods?
How else can this code be improved?

using System;
using System.Globalization;
using System.Linq;

namespace SimpleCode
{
    class Program
    {
        static void Main(string[] args)
        {
            int num1, num2, num3;

            Console.WriteLine("Введите числа");

            EnterNum(out num1);
            EnterNum(out num2);
            EnterNum(out num3);
           
            Console.WriteLine();

            Console.WriteLine(num1);
            Console.WriteLine(num2);
            Console.WriteLine(num3);
        }

        public static int EnterNum(out int number) => number = int.Parse(Console.ReadLine());
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-09-06
@PlaBetaVer

In this case, there is no benefit at all. Now, if you did the processing of the curved input, then yes, it would make sense.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question