C# 从类问题格式输入调用方法
大家好,我有这个方法,我需要插入数据。我不确定我必须以何种格式提供输入: 由于存在(string[]dic,out InformaceOplatciType[]statusplatedph)在C# 从类问题格式输入调用方法,c#,winforms,class,C#,Winforms,Class,大家好,我有这个方法,我需要插入数据。我不确定我必须以何种格式提供输入: 由于存在(string[]dic,out InformaceOplatciType[]statusplatedph)在getStatusNespolehlivyPlatce() 非常感谢你 在你们所有人的帮助下,我想到了这个: string[] ahoj = new string[] { 28156609.ToString() }; Rozhranice.StatusType[]
getStatusNespolehlivyPlatce()
非常感谢你
在你们所有人的帮助下,我想到了这个:
string[] ahoj = new string[] { 28156609.ToString() };
Rozhranice.StatusType[] ahoj2;
Rozhranice.InformaceOPlatciType[] ahoj3;
Rozhranice.rozhraniCRPDPH srv = new Rozhranice.rozhraniCRPDPH();
textBox1.Text = (srv.getStatusNespolehlivyPlatce(ahoj, out ahoj3).ToString());
下一个问题是我需要返回这些字段:
执行(srv.getStatusNespolehlivyPlatce(ahoj,out ahoj3.ToString())时代码>我只能从状态类型
返回字段,我认为我将如何接收信息平台类型
例如:
textBox1.Text = (srv.getStatusNespolehlivyPlatce(ahoj, out ahoj3).odpovedGenerovana.ToString());
srv.getStatusNespolehlivyPlatce(myStrings, out myResults);
我从StatusType
中得到了:字段odpovedGrandovana
,但我想我是在调用InformaceOPlatciType
它告诉你它想要什么,一个字符串数组在里面,一个InformaceOPlatciType数组在外面
var ahoj = new string[]{ 41354.ToString()};
InformaceOfPlatciType[] ahoj2;
richTextBox1.Text = srv.getStatusNespolehlivyPlatce(ajoh, out ahoj2);
此外,如果首先调用对象的ToString(),则不需要强制转换为类型string with(string)
沿着这条线的东西。尽管informaceofplatcype是一个自定义类型,但它所需的内容可能有限制。第一个数组需要作为普通参数传递;可以作为变量在内联或之前创建的数组。例如:
string[] myStrings = new string[] { "a", "b", "c", "d", "e" };
第二个参数是out
参数,这意味着该方法将提供一个数组。您只需提供一个适当数组类型的变量,该变量将接收结果数组:
InformaceOPlatciType[] myResults;
然后,您可以像这样调用函数:
textBox1.Text = (srv.getStatusNespolehlivyPlatce(ahoj, out ahoj3).odpovedGenerovana.ToString());
srv.getStatusNespolehlivyPlatce(myStrings, out myResults);
注意调用中使用的out
关键字
我不知道第一个数组中的值应该是什么样子,因为我不知道您正在使用的类或方法,但我想您可以访问一些文档,这些文档解释您必须在那里输入什么类型的字符串。不要使用图像来显示代码。将您的代码直接发布到问题正文中。可能是new[]{ahoj,ahoj2}
,但是很难说您想要传递给该方法的是什么。您是否检查了您正在使用的工具/代码的文档Rozhranice
?我想他们可能会在某个地方(字符串)写上1.ToString()???为什么要初始化ahoj2
?很好。当我第一次发布我的答案时,我没有意识到它是一个自定义类型,我忘记了取出初始化。谢谢。与其说它是一个自定义数组元素类型,不如说它是一个out
参数,您不需要初始化ahoj2
。非常感谢,它帮了我很多忙,您能看到我的编辑吗?我对返回的字段没有什么问题。