sharing variables in a multi-project solution

落花浮王杯 提交于 2019-12-02 07:17:19

You might have to past some code. But anyway, ensure that project A is a class library. It should be as simple as:

Project A

namespace A
{
     public class AClass  // note, this is **public**
     {
         // ctor
         public AClass { }
         public void AMethod { }
     } 
}

Project B (has A as a reference)

using A;

namespace B
{
     public class BClass
     {
         // don't actually need "A" qualifier here as we're "using A" above, this is just for clarity
         private A.AClass aClass_ = new A.AClass();

         // ctor
         public BClass()
         {
             aClass_.AMethod();
         }
     }
}

You'd have something similar in project C.

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