您可以使用包含该值的表单的字符串属性.它将简单地公开私人电子邮件字段的价值.
例如:
public class SomeForm : Form
{
public string Email
{
get
{
return txtEmail.Text;
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后从一些外部表单中,您可以显示表单并读取表单关闭后输入到电子邮件字段中的值:
using (var form = new SomeForm())
{
if (form.ShowDialog() == DialogResult.OK)
{
string email = form.Email;
// do something with the email
}
}
Run Code Online (Sandbox Code Playgroud)