当前位置:首页 > 网络编程 > WEB编程 > ASP.net > .net 里面 protected private 的变量也可以访问

.net 里面 protected private 的变量也可以访问

点击次数:19 次 发布日期:2008-11-26 23:38:18 作者:源代码网
源代码网推荐

通过 原数据可以访问,我是访问后,才发现自己怎么都操作私有字段了呢

参考代码

public class L3Data : System.ComponentModel.Component
源代码网推荐 {
源代码网推荐  private System.ComponentModel.Container components = null;
源代码网推荐        private  Page _page;
源代码网推荐  private  ArrayList LiteralList = new ArrayList();
源代码网推荐  public L3Data(System.ComponentModel.IContainer container)
源代码网推荐  {
源代码网推荐   container.Add(this);
源代码网推荐   InitializeComponent();
源代码网推荐  }

  public L3Data()
源代码网推荐  {
源代码网推荐  
源代码网推荐   InitializeComponent();
源代码网推荐  }
源代码网推荐  protected override void Dispose( bool disposing )
源代码网推荐  {
源代码网推荐   if( disposing )
源代码网推荐   {
源代码网推荐    if(components != null)
源代码网推荐    {
源代码网推荐     components.Dispose();
源代码网推荐    }
源代码网推荐   }
源代码网推荐   base.Dispose( disposing );
源代码网推荐  }
源代码网推荐        #region 组件设计器生成的代码
源代码网推荐  private void InitializeComponent()
源代码网推荐  {
源代码网推荐   components = new System.ComponentModel.Container();
源代码网推荐  }
源代码网推荐  #endregion
源代码网推荐  #region Property
源代码网推荐  public Page Page
源代码网推荐  {
源代码网推荐   get{return this._page;}
源代码网推荐   set
源代码网推荐   {  
源代码网推荐    this._page = value;
源代码网推荐    Type type = _page.GetType();
源代码网推荐    type = type.BaseType;
源代码网推荐    System.Web.UI.WebControls.Literal literal = new Literal();
源代码网推荐    System.Reflection.FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic|(BindingFlags.Static | BindingFlags.Instance));
源代码网推荐    foreach(System.Reflection.FieldInfo field in fields)
源代码网推荐    {
源代码网推荐     if(field.FieldType.Equals(literal.GetType()))
源代码网推荐      this.LiteralList.Add(field);
源代码网推荐    }
源代码网推荐    int count =0;
源代码网推荐    foreach(FieldInfo field in this.LiteralList)
源代码网推荐    {
源代码网推荐     count++;
源代码网推荐     object obj = field.GetValue(this.Page);
源代码网推荐        literal = (Literal)obj;
源代码网推荐     if(literal.Text.Equals("wx"))
源代码网推荐      literal.Text ="I can see you";
源代码网推荐     else
源代码网推荐     {
源代码网推荐      literal.Text="wangxing"+count.ToString();
源代码网推荐     }
源代码网推荐    }
源代码网推荐   }
源代码网推荐  }
源代码网推荐  #endregion
源代码网推荐 }.


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华