CSharp examples for System.Reflection:MethodInfo
Is MemberInfo Readonly
using System.Reflection; using System.Linq; using System.Collections.Generic; using System;//from www . ja v a2s .c om public class Main{ public static bool IsReadonly(this MemberInfo member) { if (member is FieldInfo) { return ((FieldInfo)member).IsInitOnly || ((FieldInfo)member).IsLiteral; } else if (member is PropertyInfo) { return !((PropertyInfo)member).CanWrite || ((PropertyInfo)member).GetSetMethod() == null || !((PropertyInfo)member).GetSetMethod().IsPublic; } return true; } }