I am doing sanitaion on my command line application written in C#. I was wondering if I need to perform a null check against the passed in string[] args
array? E.g.:
static int Main(string[] args)
{
if(args != null) { // is this needed?
}
}
Please note I have found similar question concerning Java, but was unable to find anything concerning the command line arguments in C# (& .NET in general).
Also note that I have indeed tried to pass no arguments to my command line application and have never managed to make the args array object to be null. I have also tried accessing the command line arguments using the Environment.GetCommandLineArgs()
utility function, and that was also never null.
I have also read this guide written by MS, and couldn't see any explicit guarantee that the args array will never be null.
Edit: Simplified my example.