Partial class in different namespaces

前端 未结 6 625
再見小時候
再見小時候 2020-11-30 09:50

Can I create partial class in different namespaces? Will it work correct? e.x.:

class1.cs

namespace name1
{
    public partial class Foo
    {
               


        
6条回答
  •  一生所求
    2020-11-30 10:21

    This will not work. The compiler will give you an ambiguous name error on the Foo classFoo = new Foo(); line. For partial classes to work, they must be in the same namespace because the namespace is actually part of the fully qualified name of the type.

提交回复
热议问题