C#泛型作为返回类型的写法
public static T GetObj<T>(Employee model) { T result = default(T); if (model is T) { result = (T)(object)model; //或 (T)((object)model); } return result; }
控件在设计模式时,禁止访问数据库和API
private async void SetMoldStandardResourceControl_Load(object sender, EventArgs e) { if (this.DesignMode == false) {//控件在非设计模式下才访问数据库 await SetDataSource(); m_ProjectCategories = await m_ProjectCategoryService.GetAllAsync(); } }
标签:控件,经验,C#,object,开发,result,model,设计模式 From: https://www.cnblogs.com/friend/p/17973862