我需要打开一个 FrmEscalacao,它使用名为“time”的字符串将 FrmAdmin 的信息发送到 FrmEscalacao
这是FrmAdmin的代码
public partial class FrmAdmin : Form
{
private string time;
public FrmAdmin(string time)
{
InitializeComponent();
this.time = time;
}
public void btnEscalar_Click(object sender, EventArgs e)
{
this.Hide();
FrmEscalacao f1 = new FrmEscalacao();
f1.ShowDialog();
}
这是FrmEscalacao的代码
public partial class FrmEscalacao : Form
{
public string time;
private void FrmEscalacao (string time)
{
InitializeComponent();
this.time = time;
SQLiteConnection ocon = new SQLiteConnection(Conexao.stringConexao);
DataSet ds = new DataSet();
ocon.Open();
SQLiteDataAdapter da = new SQLiteDataAdapter();
da.SelectCommand = new SQLiteCommand("Here is the SQL command");
DataTable table = new DataTable();
da.Fill(table);
BindingSource bs = new BindingSource();
bs.DataSource = table;
DataTimes.DataSource = bs;
ocon.Close();
}
它在
处返回错误private void FrmEscalacao (string time)
最佳答案
您只能拥有与类名匹配的构造函数。 如果是构造函数的声明,那么应该是
public FrmEscalacao(string time) {...}
构造函数不应该有任何返回类型。你不应该将它声明为 private
,如果它将被用来创建该类型的实例;它应该是public
。
那么你应该使用它:
FrmEscalacao f1 = new FrmEscalacao("your time");
也就是说,您必须为 string
类型的 time
参数指定值。
关于c# - 错误 "member names cannot be the same as their enclosing type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12906009/