Difficulty: Easy
Correct Answer: Add a reference to the assembly that contains the namespace. Import the namespace with a using directive. Use its elements.
Explanation:
Introduction / Context:To consume types from an external library, you must reference the assembly and optionally add using directives. This question checks the exact order of operations.
Given Data / Assumptions:
Concept / Approach:Reference resolves the binary dependency; using resolves name lookup convenience within source code. Without the reference, the compiler/linker cannot locate the types, regardless of usings.
Step-by-Step Solution:
Step 1: Add the assembly reference (Project → Add Reference).Step 2: Add a using directive to shorten type names (optional if you use fully qualified names).Step 3: Use the types in code.Verification / Alternative check:Try to compile with only using and no reference; the build fails because the type is unresolved.
Why Other Options Are Wrong:A confuses namespaces with assemblies; C misses the required reference; D is not sufficient; E is unnecessary for most scenarios and does not by itself wire references.
Common Pitfalls:Believing using imports binaries, or thinking copying the DLL beside the EXE is enough without adding a reference.
Final Answer:Add a reference to the assembly that contains the namespace. Import the namespace with a using directive. Use its elements.
Discussion & Comments