public student getStudentInfo(string id)
{
从数据库取得name等,比如reader["name"] ;
student s=new student(0;
s.id=id;
s.name=reader["name"];
return s;
}

解决方案 »

  1.   

    public student getStudent(string stuid)
    {
    }
      

  2.   

    public student getStudentInfo(string id)
    {
    从数据库取得name等,比如reader["name"] ;
    student s=new student();
    s.id=id;
    s.name=reader["name"];
    return s;
    }
      

  3.   

    调用 Student s = getStudentInfo(1);
      

  4.   

    这样呀!我还想请教大侠一个问题,为什么要定义成object类型的呢?是为了方便返回任何类型的数据吗?
      

  5.   

    一般能确定类型,就不要定义成object的。
    顺便提一下为何 czhenq(挨饿中……) 直接拷我的回贴,怪。
      

  6.   

    是挺怪的哟!再请教river723(hwg) 一个问题,就是IList,我看到要求中还有一个是这样的
    public IList getInfo(string code),我想知道什么情况下要返回IList的呢?是不是它也是一个
    类似于object的类型呢?
      

  7.   

    一般能确定类型,就不要定义成object的。同意,object类型要装箱、拆箱,浪费资源!
      

  8.   

    大家有人清楚IList的用法吗?可否指点一下!谢谢!
      

  9.   

    我现在定义了一个类,想实现插入
    public int addInfo(student studentInfo)
    {
     
    }
    正确返回1,错误返回0
    我不知道该如何用这个student对象作为一条新的数据库记录提交到数据库中,请大家指点指点