Difficulty: Easy
Correct Answer: Namespaces help developers control scope and visibility of the elements contained within them, preventing naming conflicts across assemblies.
Explanation:
Introduction / Context:
Namespaces in C#.NET are fundamental for organizing code, avoiding name clashes, and controlling visibility. This question tests whether you understand what namespaces actually do and clears up common myths about their usage in day-to-day development.
Given Data / Assumptions:
Concept / Approach:
Think of a namespace as a logical container. It does not change runtime behavior of a type but organizes source code and enables disambiguation (System.Console vs. YourCompany.Console). The using directive is a convenience; it does not change the compiled type name.
Step-by-Step Solution:
Verification / Alternative check:
Write a class without any namespace and reference it from another assembly by its global name. Also call Console.WriteLine with and without using System; you will see both approaches compile.
Why Other Options Are Wrong:
B denies nesting; C invents a non-existent default name; D ignores fully qualified names; E confuses consumer responsibilities with framework design.
Common Pitfalls:
Assuming using is mandatory, or believing types default to a special named namespace instead of the global namespace.
Final Answer:
Namespaces help developers control scope and visibility of the elements contained within them, preventing naming conflicts across assemblies.
Discussion & Comments