Answer the question
In order to leave comments, you need to log in
C# command line work?
I have not worked with the command line before, so I'm dumb. The essence of the program is this: I run the program through cmd. When I enter "Program TextFile.txt", it opens the file and everything is fine. When I enter "Program" - an error.
It is necessary to make it so that instead of an error it showed a hint "Forgot to enter a file name".
Answer the question
In order to leave comments, you need to log in
if(args == null || args.Length == 0))
{
Console.WriteLine("Забыл ввести имя файла");
}
args.Length < 1 then error
or
args.Length ==0 then error
Странно что обработать аргумент вы смогли,а проверить его наличие - нет.
static void Main(string[] args)
{
if (args.Length <= 0) { Console.WriteLine("args is null!"); return; }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question