I'm confused about what scenarios you would use one or the other.
If you have an assembly with a some public and private (or internal) types in it, then only the public types should be available from outside. Any types that are internal, or private - should not be available, in fact, their existence should not be discoverable.
Therefore, GetTypes
and GetExportedTypes
- in my mind, should return the same thing.
Clearly I'm thinking about this wrong - what is each one for?
Thanks!
From the MSDN docs:
Assembly.GetTypes Method
Return Value Type: System.Type[]
An array that contains all the types that are defined in this assembly.
From the MSDN docs:
Assembly.GetExportedTypes Method
Return Value
Type: System.Type[]
An array that represents the types defined in this assembly that are visible outside the assembly.
So the GetTypes()
call will indeed give you all types defined in an assembly - whether they're "visible" and instantiable to you or not. Might seem odd - but what if you want to inspect yourself, your own assembly (or an assembly in the same namespace as your code)? You need to be able to see everything - if needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With