471,350 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Conflicting Modifiers for Partial Class?

I have a partial class split across two files. In the class
declaration found in the first file, I state that it's a sealed class.
In the class declaration found in the second file, I do not use the
keyword sealed. This compiles fine. When I actually try to inherit
from this class, I see that it's sealed.

Can someone explain how this works? If a modifier is found in only one
part of a partial class declaration, will the modifier always apply to
every instance of the class? (Note: we'd see a compile error if I
tried to mix two opposed modifiers, like abstract and sealed.) I
didn't expect my original experiment to work, and then it did; it's
both neat and a little confusing. Any clarification is appreciated.
Thanks,

Cody Powell

Jan 12 '06 #1
1 4978
Think of partial classes as single classes which span two or more
files. Omitting parts of the class declarations are fine, as long as
they don't confict, like you've discovered. The two (or more) classes
will effectively be merged together at compile time.

Jan 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by kchalla | last post: by
9 posts views Thread by Gomaw Beoyr | last post: by
16 posts views Thread by pawel.pabich | last post: by
9 posts views Thread by Fat Elvis | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.