private void Form1_Load(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDBFilename=|DataDirectory|\Database1.mdf;
integrated Security=True;User Instance=True")
{
con.Open();
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandText = "select cityName from city";
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{ primary names=new primary();
names.id=reader.GetInt32(reader.GetOrdinal("proId"));
names.name=reader.GetString(reader.GetOrdinal("proName"));
comboBox1.Items.Add(names);
}
}
}
}
}
}
class primary
{
public string name { get ;set ;}
public int id { get ; set ;}
}
}
get set.错误显示为: “省市选择.primary.name.get”必须声明主体,因为它未标记为 abstract 或 extern ,在教学视频里,老师做的这样没有错误,我做的却显示这样的错误,求解!谢谢!
|