本文整理汇总了C#中System.Reflection.FieldInfo.IsFamily属性的典型用法代码示例。如果您正苦于以下问题:C# FieldInfo.IsFamily属性的具体用法?C# FieldInfo.IsFamily怎么用?C# FieldInfo.IsFamily使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Reflection.FieldInfo
的用法示例。
在下文中一共展示了FieldInfo.IsFamily属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Reflection;
public class Example
{
public int f_public;
internal int f_internal;
protected int f_protected;
protected internal int f_protected_public;
public static void Main()
{
Console.WriteLine("\n{0,-30}{1,-18}{2}", "", "IsAssembly", "IsFamilyOrAssembly");
Console.WriteLine("{0,-21}{1,-18}{2,-18}{3}\n",
"", "IsPublic", "IsFamily", "IsFamilyAndAssembly");
foreach (FieldInfo f in typeof(Example).GetFields(
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
{
Console.WriteLine("{0,-21}{1,-9}{2,-9}{3,-9}{4,-9}{5,-9}",
f.Name,
f.IsPublic,
f.IsAssembly,
f.IsFamily,
f.IsFamilyOrAssembly,
f.IsFamilyAndAssembly
);
}
}
}
输出:
IsAssembly IsFamilyOrAssembly IsPublic IsFamily IsFamilyAndAssembly f_public True False False False False f_internal False True False False False f_protected False False True False False f_protected_public False False False True False