铸造是C# [英] Casting isssue C#

查看:66
本文介绍了铸造是C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好guruz我有以下功能加载报告。

hello guruz i have following function which load report.

  public void loadreport(string reportname,DataSet Recordset)

   ;      {

           尝试{

 public void loadreport(string reportname, DataSet Recordset)
        {
            try {



                ; CrystalReport1 a = new CrystalReport1();

                a.SetDataSource(Recordset.Tables [0]);

              


                crystalReportViewer1.ReportSource = a;&
                crystalReportViewer1.Refresh();

            }
            catch(System.Exception s)

            {}

        }


                CrystalReport1 a = new CrystalReport1();
                a.SetDataSource(Recordset.Tables[0]);
              
                crystalReportViewer1.ReportSource = a;
                crystalReportViewer1.Refresh();
            }
            catch (System.Exception s)
            { }
        }



我想通过使用 转换reportname来使其成为dynmic CrystalReport1 a =新的CrystalReport1();

而不是这样的结果

  if(reportname ==" test")

  ;  {

    CrystalReport1 a = new CrystalReport1();

  }

  if (reportname ==" test2")

   {

    CrystalReport2 a = new CrystalReport2();

  }


I want to make it dynmic by casting reportname with  CrystalReport1 a = new CrystalReport1();
rather than doing like this
 if(reportname=="test")
  {
   CrystalReport1 a = new CrystalReport1();
  }
 if(reportname=="test2")
  {
   CrystalReport2 a = new CrystalReport2();
  }


$
i想要将字符串转换为水晶报表对象

我该怎么做才能帮助我

问候


i want to cast string to crystal report object
how can i do that help me
regards

Ali Muhammad

Ali Muhammad

推荐答案

我认为这不是一般的C#问题,而是一个CrystalReports软件(如果你正在使用它?)。您应该在文档中查看该问题或在论坛中搜索帮助。

I don't think this is a C# problem in general but one of the CrystalReports Software (if this is what you are using?). You should look that problem up in the documentation or search for help in their forums.

如果这不是CrystalReports而是您自己的类,那么没有人可以真正帮助您,因为这是您的决定如果你将一个字符串转换为CrystalReports会发生什么。

If this isn't CrystalReports but your own class, then no one can really help you because it's your decision what happens if you cast a string to CrystalReports.

问候,

Steve。


这篇关于铸造是C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆