Why can't i use partly qualified namespaces during object initialization?

前端 未结 4 1792
不知归路
不知归路 2020-12-28 20:59

I suspect this is a question which has been asked many times before but i haven\'t found one.

I normally use fully qualified namespaces if i don\'t use that type of

4条回答
  •  北海茫月
    2020-12-28 21:13

    Partial namespaces will work only if your current class is part of that partial namespace. Using statements are not considered for accessing types through partial namespace.

    For instance this will work because your current namespace is ns_1

    namespace ns_1
    {
        public class Program
        {
            public Program()
            {
                var no_foo = new ns_1_1.Foo();
            }
        }
    }
    

提交回复
热议问题