Knowledge Check - Large Programs
1. True/False. A using
directive makes it so that you do not need to use fully qualified names.
True. They allow you to use simple names for types in the namespace identified by the using
directive.
2. What namespace are each of the following types in? (a) Console
, (b) List<T>
, (c) StringBuilder
.
(a) Console
is in the System
namespace.
(b) List<T>
is in the System.Collections.Generic
namespaces.
(c) StringBuilder
is in the System.Text
namespace.
.NET 6 projects include have the equivalent of having a global using
directive for System
and System.Collections.Generic
, so of the three, the only one you will usually need to add an explicit using
directive for would be System.Text
.
3. What keyword is used to declare a namespace?
The namespace
keyword is used to indicate the beginning of a namespace.
True/False. You should never write your own Program
class and Main
method.
False. This is a matter of opinion, not a matter of correctness.
If you like writing out your own Program
and Main
, feel free to do so.
I, personally, like the newer style, where you don’t need to write those out yourself, but both work fine.