Created
April 19, 2012 09:25
-
-
Save SimonCropp/2419932 to your computer and use it in GitHub Desktop.
Bypass Protected Constructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BaseClass | |
| { | |
| protected BaseClass() | |
| { | |
| } | |
| } | |
| public class BypassClass : BaseClass | |
| { | |
| public static BaseClass GetBaseClass() | |
| { | |
| return new BypassClass(); | |
| } | |
| } | |
| public class Foo | |
| { | |
| public void Bar() | |
| { | |
| BaseClass baseClass = BypassClass.GetBaseClass(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment