C#.NET — handling type name conflicts when Point class exists in both n1 and n2 namespaces.

C# Programming Namespaces Difficulty: Medium
Choose an option
  • A
    Import n1 inside Main() and declare Point.
  • B
    Use n1.Point and n2.Point fully qualified names after imports.
  • C
    Use using n1 and using n2 inside Main().
  • D
    using n1; using n2; then use n1.Point and n2.Point explicitly.

Answer

Correct Answer: using n1; using n2; then use n1.Point and n2.Point explicitly.

Explanation

Fact:When two namespaces contain the same class name, you must qualify with the namespace to disambiguate. Both using directives can be present, but class references must be fully qualified.

Final Answer:using n1; using n2; then use n1.Point and n2.Point explicitly.

Discussion & Comments
No comments yet. Be the first to comment!
Join Discussion