Skip to content

Instantly share code, notes, and snippets.

@vdonchev
Created March 19, 2016 15:37
Show Gist options
  • Select an option

  • Save vdonchev/4b2d985a1df5210b9940 to your computer and use it in GitHub Desktop.

Select an option

Save vdonchev/4b2d985a1df5210b9940 to your computer and use it in GitHub Desktop.
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