Microsoft.VisualBasic.Interaction.InputBox("Give an ID to mutate", "Mutation", "Enter your ID");
我能够读取输入,但如何?
另外,如果我按 1 之类的数字,是否有可能获得以下所有信息?
Mp3Player player1 = new Mp3Player(1, "GET Technologies .inc", "HF 410", 4096, 129.95M, 500);
Microsoft.VisualBasic.Interaction.InputBox("Give an ID to mutate", "Mutation", "Enter your ID");
我能够读取输入,但如何?
另外,如果我按 1 之类的数字,是否有可能获得以下所有信息?
Mp3Player player1 = new Mp3Player(1, "GET Technologies .inc", "HF 410", 4096, 129.95M, 500);
您可以分配结果:
string id = Microsoft.VisualBasic.Interaction.InputBox("Give an ID to mutate", "Mutation", "Enter your ID");
如果您尝试将其转换为数字,则需要将字符串转换为数字:
string idString = Microsoft.VisualBasic.Interaction.InputBox("Give an ID to mutate", "Mutation", "Enter your ID");
int id;
if (int.TryParse(idString, out id))
{
Mp3Player player = new Mp3Player(id, "GET Technologies .inc", "HF 410", 4096, 129.95M, 500);
}
else
{
// The user typed something that wasn't a number
}