GetConstructor method and private constructors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug

    GetConstructor method and private constructors

    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.GetConstru ctors(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?

  • Jon Skeet [C# MVP]

    #2
    Re: GetConstructor method and private constructors

    Doug wrote:[color=blue]
    > 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.GetConstru ctors(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?[/color]

    You need GetConstructors (BindingFlags.N onPublic |
    BindingFlags.In stance);

    Jon

    Comment

    • Doug

      #3
      Re: GetConstructor method and private constructors

      Thank you, that was exactly what I was lookin for!

      Comment

      Working...