GetConstructor method and private constructors

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

I am using reflection to read an assembly and I have a class that has
only a private constructor. However when I use the following method.


Type.GetConstructors(BindFlags.NonPublic);


It does not pick up the private constructor. Instead it reads that
there are no constructors. How do I use this method to determine there

is a private constructor there?
 
Doug said:
I am using reflection to read an assembly and I have a class that has
only a private constructor. However when I use the following method.

Type.GetConstructors(BindFlags.NonPublic);

It does not pick up the private constructor. Instead it reads that
there are no constructors. How do I use this method to determine there
is a private constructor there?

You need GetConstructors (BindingFlags.NonPublic |
BindingFlags.Instance);

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top