Created
March 19, 2016 15:37
-
-
Save vdonchev/4b2d985a1df5210b9940 to your computer and use it in GitHub Desktop.
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
| namespace ConsoleApplication2 | |
| { | |
| using System; | |
| using System.Linq; | |
| using System.Reflection; | |
| class Test | |
| { | |
| string @private; | |
| internal string @internal; | |
| public string @public; | |
| } | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var info = typeof (Test).GetFields(BindingFlags.NonPublic | BindingFlags.Instance) | |
| .FirstOrDefault(f => f.Name == "private"); | |
| Console.WriteLine(info.IsPrivate ? "Its private" : "Its not"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment