Jay Riggs <ja*********@gmail.comwrote:
Write a small test program and take a look at the IL; you'll see that
classes without a defined scope are made public.
No they're not, they're internal for top-level classes, and private for
nested classes. The C# rule is that the default is always the most
private applicable access.
Example - I compiled this C#:
class Test
{
static void Main()
{
}
}
and the resulting IL for the class was:
..class private auto ansi beforefieldinit Test
extends [mscorlib]System.Object
{
.method private hidebysig static void Main() cil managed
{
.entrypoint
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Test::Main
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Test::.ctor
} // end of class Test
The "private" of the class here actually means C#'s "internal" - top
level classes can only be public or private as far as IL is concerned.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too