0
我试图将Button1单击事件中生成的变量的值传递给另一个函数(function2)。什么是最有效的方法来做到这一点?会话对象?将一个函数的值传递给另一个函数
private static string createAuthCode()
{
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] buff = new byte[5];
rng.GetBytes(buff);
return Convert.ToBase64String(buff);
}
protected void Button1_Click(object sender, EventArgs e)
{
//code
//..
try {
...
string authCode = createAuthCode();
}
//code
//..
function2();
}
protected void function2()
{
//I want to access authCode here
}
你不能更改'function2'的签名吗?如果'function2'只能从'Button1_Click'被调用,那么为什么不把它作为参数传递 –