跨项目的部分课程课程、部分、项目

2023-09-03 03:32:28 作者:忘卜掉的曾经

是否有可能在项目中有部分类。

Is it possible to have partial classes across projects.

例如。项目1有一个客户类。 项目2这是一个可选模块,通过连接一个订单班,并利用原有的客户类增加了客户的类。

e.g. Project 1 has a Customer Class. Project2 which is an optional module adds to the customer class by attaching an order class, and utilising the original Customer Class.

推荐答案

您无法使用部分关键字分裂code为项目之间的一类。该部分关键词是一个编译器的技巧;编译器将输出一个特定的类出它找到的部分,所以类的所有部分必须使用相同的二进制文件存在。一旦类被编译,没有一丝它是一个局部类的离开了。

You cannot use the partial keyword to split the code for a class between projects. The partial keyword is a compiler trick; the compiler will output one single class out of the parts it finds, so all parts of the class must exist with the same binary file. Once the class is compiled, there is no trace left of it being a partial class.

如果你想扩展现有的类,你要么需要继承它(如果它不密封),或者创建自己的新的类,它包含您希望从信息相结合的类。

If you want to extend an existing class you will either need to inherit it (if it is not sealed), or create your own new class that contains the classes that you wish to combine information from.