【发布时间】:2015-07-07 02:13:02
【问题描述】:
我想在 C# 中使用一个名为 GenerateKeys 的类来完成一个命令,该类中有一个名为 GenKeyA(classValue); 的函数,它是从 Visual Studio 13 中的默认 button1_click 事件处理程序调用的,使用表单字符串变量formValue 就像这样。 GenKeyA(formValue),通过这样做,我想将返回的字符串发送到 textBox1.Text 变量。如果我有任何错误,请纠正我!
public class GenerateKeys
/// The Class
{
/// string Variable.
string classValue = "";
/// Called from button1_click
private void GenKeyA (string classValue)
{
Random rand = new Random();
classValue = ""+rand.Next(0,9)+""+rand.Next(0,9)+""+rand.Next(0,9)+"";
/// from here, i wish to return the string classValue to
/// the form1.frmValue string then send that to textBox1.Text = formValue;
}
}
【问题讨论】:
-
你有什么问题?需要把
GenKeyA的返回类型改一下,大概是string -
我希望为函数使用一个类,并且在该函数中,我想创建一个字符串,该字符串可以通过该类和函数传递回主窗体变量字符串,然后传递到一个文本框。
标签: c# string class parameter-passing argument-passing