62,025
社区成员
发帖
与我相关
我的任务
分享
private Lazy<Method> m_MethodSearch;
//private Lazy<Method> m_MethodSearch=new Lazy<Method>();//延迟调用字段类型的默认构造函数
public Method MethodSearch {
get { return m_MethodSearch.Value; }
set { m_MethodSearch = new Lazy<Method>(() => { return value; }); }
}
//在构造函数调用此方法
private void LazyInitialize() {
//传入匿名委托,可以调用任何自定义初始化处理
m_MethodSearch = new Lazy<Method>(() => { return new Method(); });
}
protected virtual void LazyInitialize() {
this.m_MethodSearch = new Lazy<Method>(
() => { return this.GetMethod(METHODLINE_SEARCH); });
//......
}