开发者

Multiple partial classes with a single namespace returning error

开发者 https://www.devze.com 2023-01-28 08:30 出处:网络
I\'ve declared a partial class with name \"BusinessLayer\" in BL namespace, but now I want to add another class with same name, and with keyword \"partial\" in that namespace. But Whenever I try to ad

I've declared a partial class with name "BusinessLayer" in BL namespace, but now I want to add another class with same name, and with keyword "partial" in that namespace. But Whenever I try to add class with with name "BusinessLayer", I'm getting an error, saying I can't declared multiple classes with same name in a 开发者_如何学JAVAnamespace. Then how can I use partial classes in a single namespace?


I would fix your code if you'd write some, even just as an example.

Anyway, you should tag both as "partial".
Any declaration of this class, anywhere, should have the "partial" keyword in order to allow it to compile properly.


All declarations of the class must have the partial keyword, otherwise they will be interpreted as different classes and being in the same namespace will cause a compile time error.

My best guess is you're missing a partial keyword somewhere.

Edit: By the way, partial classes can only be declared in the same assembly, iirc. So all parts of the partial class need to be in the same assembly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号