Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
where T : class, new()

Please suggest me.
Posted
Updated 30-Sep-11 22:03pm
v5

1 solution

What do you mean with "I need to do something with"?

This
C#
where T : class, new()
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.
 
Share this answer
 
Comments
mmdullah 1-Oct-11 4:27am    
I mean that, If I can declare a base class for all of my crystal Reports then, I can declare it as where T : myBasicReportClass, new() and thus I can get the SetDataSource Method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900