如何使用泛型调用水晶报表 [英] How to call a crystal report using Generics
本文介绍了如何使用泛型调用水晶报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
请查看以下方法:
Hello,
please look at the following method:
public static bool BindReport<t>(CrystalReportViewer viewer, DataTable dt, List<string> paramNames, List<string> paramValues) where T : class, new()
{
try
{
SetParameters(paramNames, paramValues, viewer);
T rpt = new T();
rpt.SetDataSource(dt); /*actually no "SetDataSource" method found; but i need that*/
viewer.ReportSource = rpt;
}
catch (exception ex)
{
throw ex;
}
return true;
}
我需要对
I need to do something with
where T : class, new()
请建议我.
Please suggest me.
推荐答案
我需要做点什么"是什么意思?
此
What do you mean with "I need to do something with"?
This
where T : class, new()
表示T
类型必须是一个类并具有构造函数.看看类型参数的约束(C#编程指南) [
means that the T
type must be a class and have a constructor. Have a look at Constraints on Type Parameters (C# Programming Guide)[^] for a more detailed description.
这篇关于如何使用泛型调用水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文