According to MSDN Documentation for partial classes :
All the parts must have the same accessibility, such as public, private, and so on.
but if you create a WindowsForm application, you will have the default Form class in two partial classes.
The code behind :
public partial class Form1 : Form
{
...
}
and the designer :
partial class Form1
{
...
}
Access modifiers are different, but it will compile.
Am I missing something here?
If you don't specify the access modifier in a part of a partial class, it uses the same access modifier as the other part.
Relevant part from the C# 5 spec: §10.2.2
When a partial type declaration includes an accessibility specification (the public, protected, internal, and private modifiers) it must agree with all other parts that include an accessibility specification. If no part of a partial type includes an accessibility specification, the type is given the appropriate default accessibility (§3.5.1).
So the spec says that the accessibility must agree with other parts if it is specified; in other words, it doesn't have to be specified in every part. The wording could probably be changed to be less ambiguous, though...