从不同的程序集中用内部构造函数实例化一个 class
Instantiate a class with internal ctor, from a different assembly
我认为 internal
构造函数无法从不同的程序集访问。今天我第一次真正需要使用这个想法,但它并没有像我预期的那样工作——它可以从不同的程序集访问。
namespace A {
public class AA {
internal AA() { }
}
}
namespace TestNamespace {
public class TestClass {
public void TestMethod() {
var instance = new A.AA(); // <-- this compiles!
}
}
}
...所以我做错了,或者不知道我在做什么。
Assembly != Namespace
Namespaces provide a logical organizational system. Namespaces are
used both as an "internal" organization system for a program, and as
an "external" organization system — a way of presenting program
elements that are exposed to other programs.
同时
Assemblies are used for
physical packaging and deployment. An assembly may contain types, the
executable code used to implement these types, and references to other
assemblies.
程序集通常是项目,C#
明智。
了解更多信息 here。
我认为 internal
构造函数无法从不同的程序集访问。今天我第一次真正需要使用这个想法,但它并没有像我预期的那样工作——它可以从不同的程序集访问。
namespace A {
public class AA {
internal AA() { }
}
}
namespace TestNamespace {
public class TestClass {
public void TestMethod() {
var instance = new A.AA(); // <-- this compiles!
}
}
}
...所以我做错了,或者不知道我在做什么。
Assembly != Namespace
Namespaces provide a logical organizational system. Namespaces are used both as an "internal" organization system for a program, and as an "external" organization system — a way of presenting program elements that are exposed to other programs.
同时
Assemblies are used for physical packaging and deployment. An assembly may contain types, the executable code used to implement these types, and references to other assemblies.
程序集通常是项目,C#
明智。
了解更多信息 here。