C # sprawdź, czy przekazałeś argumenty, czy nie
Mam ten kod:
public static void Main(string[] args)
{
if (string.IsNullOrEmpty(args[0])) // Warning : Index was out of the bounds of the array
{
ComputeNoParam cptern = new ComputeNoParam();
cptern.ComputeWithoutParameters();
}
else
{
ComputeParam cpter = new ComputeParam();
foreach (string s in args){...}
}
}
Próbowałem teżif(args.Length==0)
, ale nadal nie działa.
Zasadniczo chcę się dowiedzieć, czy użytkownik wywołał program za pomocą argumentów. Jeśli nie, program poprosi o wprowadzenie danych.
Jak mogę to zrobić? Z góry dziękuję.