How to access namespace which is part of different project?

倖福魔咒の 提交于 2019-12-01 20:58:29

Make sure the classes you want to access are public. So suppose you have the following class in Project 2:

namespace Project2
{
    public class Foo { }
}

In Project 1 after you've referenced Project 2 you can use this class:

namespace Project1
{
    using Project2;

    public class Bar
    {
        public Bar()
        {
            Foo foo = new Foo();
        }
    }
}

Import is a Visual Basic.NET term. In C# you would use using.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!