小编Isu*_*uru的帖子

C#中的对象初始化

当我声明如下:

class Professor
{
  string profid;
  public string ProfessorID
  {
     get { return profid;}
     set { profid=value;}
  }

  student st;

}


class student
{
  string name;
  string id;
  public string Name
  {
     get  { return name;}
     set  { name=value; } 
  }

 public string StudentID
 {
   get { return id;}
   set { id=value; }
 }

}


public void GetDetails()
{
  Professor prf=new Professor(){ ProfessorID=1, how to initialize student here?};

}
Run Code Online (Sandbox Code Playgroud)

在GetDetails()里面我如何初始化学生?

.net c# initialization object

2
推荐指数
1
解决办法
936
查看次数

标签 统计

.net ×1

c# ×1

initialization ×1

object ×1