December 2018
Beginner to intermediate
668 pages
15h 30m
English
Add the following statements inside the Main method to check whether this console application has any arguments passed to it:
if (args.Length == 0)
{
WriteLine("There are no arguments.");
}
else
{
WriteLine("There is at least one argument.");
}
As there is only a single statement inside each block, this code can be written without the curly braces, as shown in the following code:
if (args.Length == 0)
WriteLine("There are no arguments.");
else
WriteLine("There is at least one argument.");
This style of the if statement is not recommended because it can introduce serious bugs, for example, the infamous #gotofail bug in Apple's iPhone operating system. For 18 months after Apple's iOS 6 was released, it had a bug in its Secure Sockets ...
Read now
Unlock full access