关于Dispose在aspx.cs上的使用

来源:互联网 发布:佳能打印软件下载 编辑:程序博客网 时间:2024/04/30 09:07
在aspx.cs上定义属性,比如:
#region 属性块
    
private int _taskID = 0;
    
public int TaskID
    {
        
get
        {
            
return _taskID;
        }
        
set
        {
            
if (String.IsNullOrEmpty(value.ToString()))
            {
                
throw new ArgumentNullException(value.ToString(), "null value for TaskID");
            }
            
if (!XPWY.Utility.WebValidate.IsInteger(value.ToString()))
            {
                
throw new InvalidCastException("invalidCastException for TaskID");
            }
            _taskID 
= value;
        }
    }
    
private TQL_Section ts = null;
    
private TQL_Task tt = null;
    
/// <summary>
    
/// TQL_TopQuestionTitle
    
/// </summary>
    private IList<TQL_TopQuestionTitle> ttq = null;
    
/// <summary>
    
/// TQL_QuestionTitle
    
/// </summary>
    private IList<TQL_QuestionTitle> tqt = null;
    
/// <summary>
    
/// TQL_ChoiceVoice
    
/// </summary>
    private IList<TQL_ChoiceVice> tcv = null;
    
private int QuestionFirstNum = 0;
    
private int QuestionSecondNum = 0;
    
#endregion
 然后重写dispose()方法,如下:
释放资源
这样就可以及时释放资源,而且方便管理
原创粉丝点击