What I am trying to do is ensure a Argument being passed from the command line is between a specific set of characters, however the code doesn't seem to be highlighting any issues when a value outside the acceptable range is used.
if (args[1].Length < 10 && args[1].Length > 40) // Test to see if the password is between 10 and 40 characters
{
Console.WriteLine("Please use a password between 10 and 40 characters");
Environment.Exit(0);
}
I was wondering if anyone might have any suggestions for why this is not working. The arguments being passed are -e password file1.txt file2.txt
Thanks in Advance!
Alistair
您的逻辑有误,应||
if (args[1].Length < 10 || args[1].Length > 40) // Test to se
该参数不能在长度上比10 更小 并且比40.你应该选择能满足这些条件(使用较长的 有条件或操作员 ),但没有严格的两项:
if (args[1].Length < 10 || args[1].Length > 40)
It should be:
if (args[1].Length < 10 || args[1].Length > 40) // Test to see if the password is between 10 and 40 characters
{
Console.WriteLine("Please use a password between 10 and 40 characters");
Environment.Exit(0);
}
You gave wrong conditions:
It should be:
if (args[1].Length < 10 || args[1].Length > 40)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.