user310291
user310291

Reputation: 38228

In C# why do I need to prefix MYClass when I name its namespace with MYClass also?

I have created a class:

namespace MyClass {    

    public partial class MyClass: UserControl {

I want to use it in another project so I add the above project as reference and the instruction

using MyClass

but I still have to refer to the class as

MyClass.MyClass

and not just

MyClass

Why ?

Upvotes: 0

Views: 200

Answers (1)

Oded
Oded

Reputation: 499212

You may have other types with the same name in the current scope, so the compiler will require you to use the fully qualified name in order to distinguish the exact one you mean.

Upvotes: 5

Related Questions