开发者

Add an attribute to an existing C# class without losing existing extension methods?

I ha开发者_StackOverflow中文版ve an existing partial class that has extension methods applied to it, in one project.

I want to add an attribute to that class within a different project, but when I create a second partial class the extension methods disappear.

Initially I created the class with the new attribute as a child of the original class, but I want to avoid the tedious up-cast of an instance of the original class to the new child class (though this may be the "best" way in the end).

Is there anyway to add the attribute without losing the extension methods, without using inheritance?


You can't declare a partial class across projects - it's got to be in a single project.

Basically if you need an extra attribute on the class, you'll have to put that in the original project.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜