我会尽力解释。
我正在使用一个类InputBox
并使用一种方法shutownTime
class InputBox
{
public static DialogResult shutdownTime(string title, string promptText, ref string value)
{
我正在返回值
DialogResult dialogResult = form.ShowDialog();
return dialogResult;
在另一种方法中,我将值从另一个类传递给它。
string title2 = "Shutdown Timer";
string promptText = "How long would you like to delay the shutdown in minutes?";
string value = "0";
InputBox.shutdownTime(title2, promptText, ref value);
一切正常,但是当我按下 OK 按钮时,但如果我从shutdownTime
方法中按下 Cancel 按钮,调试会显示返回值为 Cancel
//shutdownTime()
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
我无法得到的是,如果我按取消,我如何在使用后检查该值
InputBox.shutdownTime(title2, promptText, ref value);
因为我可以按“确定”或“取消”,它只是继续代码。
希望我有道理,谢谢