目前,我已经把这一切都列出来了:
public static string Encrypt<T>(string anything)
{
//Stuff can go here
}
Run Code Online (Sandbox Code Playgroud)
当我按下按钮时,我希望能够在 Encrypt 中运行所有代码。是否可以这样做,如果可以,我该怎么做?
假设你的 aspx 按钮是
<asp:Button runat="server" text="Encrypt" id="btnencrypt" onclick="btnencrypt_Click" />
Run Code Online (Sandbox Code Playgroud)
您的服务器端事件将是这样的:
protected void btnencrypt_Click(object sender,EventArgs e)
{
// Supposing that the Encrypt method is not in the current class.
OtherClass.Encrypt(anystring);
}
Run Code Online (Sandbox Code Playgroud)
如果 Encrypt 方法在同一个类中,那么您可以直接编写方法名称,如:
Encrypt(anystring);
Run Code Online (Sandbox Code Playgroud)
你不需要 . 所以你的加密方法将是这样的:
public static string Encrypt(string inputstring)
{
//Encryption code.
}
Run Code Online (Sandbox Code Playgroud)
希望你能从这里得到你的答案......