I am generating a dynamic assembly using Reflection.Emit and everything works fine but the generated class is marked as internal sealed
due to the following code:
var typeBuilder = moduleBuilder.DefineType("MyNamespace.Program", TypeAttributes.Class | TypeAttributes.Sealed);
I don't see any of the TypeAttributes
members that would hint at static
. It does not seem to be just a compiler convenience as I can see manually written classes show up as static
in reflector tools.
How could I mark my own type as static?
Got it to work using:
var builderType = builderModule.DefineType("MyNamespace.Program", TypeAttributes.Class | TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.Abstract);
This gives internal static
which is what I wanted.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.