Pregunta

I have 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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top