C# 中创建一个对象,问一下这个对象所有的成员是什么?谢谢C#高手。public class c
{
}
c obj = new c()obj对象是一个空类(类里面什么也没有)实例化而来的。但我相信除了继承自System.Object的成员之外。微软肯定还对这个对象添加了不少私有成员(只是不暴露接口而已,这可能涉及.net framwork底层)。怎样获得这些私有成员。还有,他们各有什么意义。
{
}
c obj = new c()obj对象是一个空类(类里面什么也没有)实例化而来的。但我相信除了继承自System.Object的成员之外。微软肯定还对这个对象添加了不少私有成员(只是不暴露接口而已,这可能涉及.net framwork底层)。怎样获得这些私有成员。还有,他们各有什么意义。
解决方案 »
- 飞哥,求助,请进!
- 大家帮我看看我这段代码哪错了,List.Items.Count总是零
- BeginInvoke是不是多线程?
- 在VS2008(C#)环境下用什么控件实现vista的透明窗体?
- 重新发贴!datagrid和dataview问题!急啊!
- SQL语句我应该写在哪里???????
- 做win form的时候,忘记了一个东西,就是关了X后,不让程序结束
- 用.net如何连接到局域网上的active directory服务器 在线等!进者有分。
- c#中如何将html中的table转化为xml
- 现在数据库服务器是linux的上边有oracle..用c#作前端如何连接呢
- c# 实现BHO 文件浏览器
- 怎么区分
但我相信除了继承自 System.Object 的成员(ToString、GetHashCode等等)之外。微软肯定还对这个对象添加了不少私有成员。
[Serializable, ComVisible(true), ClassInterface(ClassInterfaceType.AutoDual)]
public class Object
{
// Methods
public virtual bool Equals(object obj)
{
return InternalEquals(this, obj);
} public static bool Equals(object objA, object objB)
{
return ((objA == objB) || (((objA != null) && (objB != null)) && objA.Equals(objB)));
} private void FieldGetter(string typeName, string fieldName, ref object val)
{
val = this.GetFieldInfo(typeName, fieldName).GetValue(this);
} private void FieldSetter(string typeName, string fieldName, object val)
{
FieldInfo fieldInfo = this.GetFieldInfo(typeName, fieldName);
if (fieldInfo.IsInitOnly)
{
throw new FieldAccessException(Environment.GetResourceString("FieldAccess_InitOnly"));
}
Message.CoerceArg(val, fieldInfo.FieldType);
fieldInfo.SetValue(this, val);
} [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected override void Finalize()
{
} private FieldInfo GetFieldInfo(string typeName, string fieldName)
{
Type baseType = this.GetType();
while (baseType != null)
{
if (baseType.FullName.Equals(typeName))
{
break;
}
baseType = baseType.BaseType;
}
if (baseType == null)
{
throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_BadType"), new object[] { typeName }));
}
FieldInfo field = baseType.GetField(fieldName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
if (field == null)
{
throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_BadField"), new object[] { fieldName, typeName }));
}
return field;
} public virtual int GetHashCode()
{
return InternalGetHashCode(this);
} [MethodImpl(MethodImplOptions.InternalCall)]
public extern Type GetType();
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern bool InternalEquals(object objA, object objB);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern int InternalGetHashCode(object obj);
[MethodImpl(MethodImplOptions.InternalCall)]
protected extern object MemberwiseClone();
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static bool ReferenceEquals(object objA, object objB)
{
return (objA == objB);
} public virtual string ToString()
{
return this.GetType().ToString();
}
}