本文整理汇总了C#中System.Reflection.FieldInfo.Count方法的典型用法代码示例。如果您正苦于以下问题:C# FieldInfo.Count方法的具体用法?C# FieldInfo.Count怎么用?C# FieldInfo.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.FieldInfo
的用法示例。
在下文中一共展示了FieldInfo.Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DescribeFields
static string[] DescribeFields(FieldInfo[] fi)
{
string[] result = null;
string mods;
FieldInfo f;
result = new string[fi.Count()];
for (int i = 0; i < fi.Count(); i++)
{
f = fi[i];
mods = "";
if (f.IsPublic)
{
mods = mods + "public ";
}
if (f.IsPrivate)
{
mods = mods + "private ";
}
if (f.IsFamily)
{
mods = mods + "protected ";
}
if (f.IsLiteral)
{
mods = mods + "const ";
}
else if (f.IsStatic)
{
mods = mods + "static ";
}
if (f.IsInitOnly)
{
mods = mods + "readonly ";
}
result[i] = string.Format("{0} {1};", f.FieldType, f.Name);
result[i] = mods + result[i];
}
return result;
}
示例2: VerifyFieldsEquality
private static void VerifyFieldsEquality(FieldInfo[] fieldInfo1, FieldInfo[] fieldInfo2)
{
if (TestHelper.AreNotNull(fieldInfo1, fieldInfo2))
{
Assert.AreEqual(fieldInfo1.Count(), fieldInfo2.Count());
foreach (FieldInfo field1 in fieldInfo1)
{
FieldInfo field2 = fieldInfo2.First(f => f.Name == field1.Name);
Assert.IsTrue(AreTypesEqual(field2.FieldType, field1.FieldType));
}
}
}