Created
August 22, 2014 22:48
-
-
Save svick/5e60c304ee73598f93f3 to your computer and use it in GitHub Desktop.
C# 6.0 primary constructor accessibility
This file contains 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
class Program | |
{ | |
static void Main() | |
{ | |
new PublicConstructor(""); // OK | |
new PrivateConstructor(""); // error CS0122: 'Program.PrivateConstructor.PrivateConstructor(string)' is inaccessible due to its protection level | |
new PrimaryConstructor(""); // OK | |
} | |
private class PrimaryConstructor(string firstName) | |
{ | |
} | |
private class PublicConstructor | |
{ | |
public PublicConstructor(string firstName) | |
{ | |
} | |
} | |
private class PrivateConstructor | |
{ | |
private PrivateConstructor(string firstName) | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment