如何将参数传递给当前类中另一个类的函数 [英] How to pass arguments to function of another class from current class

查看:176
本文介绍了如何将参数传递给当前类中另一个类的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要将参数从一个表格的功能传递到另一个表格的功能



我正在做这样的事情



Hi,

I need to pass arguments from function of one form to function of another form

I am doing something like this

public void GenerateGatewayMessagesPlots(string dataLogFile, string numofBuses, string select1, string select2, string select3, string select4)
       {
           List<GatewayMessageDetails> GWmsgDetailsList = new List<GatewayMessageDetails>();

           GWmsgDetailsList =  new GatewayMsgIDs(dataLogFile).ResponseTimeofMsgs(numofBuses, select1, select2, select3, select4);
           PlotGWMsgsData(GWmsgDetailsList);
       }





但我不想创建表格GatewayMsgIDs的新实例







But I do not want to create new instance of the form GatewayMsgIDs


new GatewayMsgIDs(dataLogFile).ResponseTimeofMsgs(numofBuses, select1, select2, select3, select4);





有什么方法可以删除新关键字并将参数传递给表格



因为当我使用new关键字时,默认情况下某些参数在形式为GatewayMsgIDs时为null



有没有办法我可以解决这个问题???





谢谢

John



Is there some way that I can remove new keyword and pass the arguments to the form

Because when I am using new keyword some parameters are by default going to null in the form GatewayMsgIDs

Is there some way that I can fix this???


Thanks
John

推荐答案

将参数传递给另一个表单的方法当然是调用另一种形式的方法。那就是你必须在'接收表单'中创建一个公共方法,以接受'发送'中的参数。
The way for 'passing the arguments to the other form' is calling a method of the other form, of course. That is you have to create a public method in the 'receiving form' in order to accept the parameters from the 'sending' one.


这篇关于如何将参数传递给当前类中另一个类的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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