qq_36781622
C从入门到入土
2017-09-12 03:19

winform数组赋值出现未将对象引用设置到对象的实例。求教

  • winform
  • 对象
  • 实例
    public DB[] db = new DB[10];//声明实例化数组
    public void Bind()
    {
        label1.Text = "题目" + (index + 1);
        textBox1.Text = TypeForm.DT.Rows[index][1].ToString();
        radioButton1.Text = TypeForm.DT.Rows[index][4].ToString();
        radioButton2.Text = TypeForm.DT.Rows[index][5].ToString();
        radioButton3.Text = TypeForm.DT.Rows[index][6].ToString();
        radioButton4.Text = TypeForm.DT.Rows[index][7].ToString();

        db[index].T_ID = Convert.ToInt32(TypeForm.DT.Rows[index][0].T oStr ing());///未将对象引用设置到对象的实例。
                    db[index].ID = index + 1;
        db[index].Title = TypeForm.DT.Rows[index][1].ToString();
        db[index].Answer = tag;
        radioButton1.Checked = false;
        radioButton2.Checked = false;
        radioButton3.Checked = false;
        radioButton4.Checked = false;
}

    //类
    public class DB
{
    public int T_ID = 0;      //数据库ID
    public int ID = 0;             //题目序号
    public string Title = string.Empty;       //题目内容
    public string Answer = string.Empty;  //答案
}
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答