自己写一个类继承于TCPCLIENT就可以调用啦,呵。
因为受保护的只能是子类中调用

解决方案 »

  1.   

    I want an instance, why don't you give some example code?
      

  2.   

    就如 nga96() 所说的,你只要新建一个类(如 MyTcpClient),并在类中建立一个方法:
    public bool GetActive() { return this.Active; }然后用你的MyTcpClient代替TcpClient就可以啦。
    MyTcpClient myTcp = new MyTcpClient();
    ...
    bool bActive = myTcp.GetActive();------------------------------------------------------------------------------------
    如果有你某些理由,使你不能通过产生新类来代替TcpClient。
    那我给你一把锋利的双刃剑,要是你自己学艺不精,误伤自己可不要怪我(开玩笑 :) ):
    // 引入 System.Reflection
    using System;
    using System.Reflection;....// 你的TcpClient实例
    TcpClient myTcpClient = new TcpClient();....// *****************************************************************************
    // 取TcpClient的类型信息
    Type tcpClientType = Type.GetType("System.Net.Sockets.TcpClient");
    // 取Active属性信息
    PropertyInfo propActive = tcpClientType.getProperty("Active");
    // 取 Active 的值
    object objValue = propActive.GetValue(myTcpClient, null);
    // *****************************************************************************