我正在尝试做一个博客项目,我正在使用 ado.net,我有 3 层架构。在一个类库中,我有诸如User和之类的类Comments:
public class User
{
 public int userID{ get; set; }
 public string userName{ get; set; }
 public string userPassword { get; set; }
 public string userMail{ get; set; }
}
public class Comments
{
public int ID { get; set; }
public int userID{ get; set; }
public string commentHeader{ get; set; }
public string commentContent{ get; set; }
}
我想在课堂上拥有一userName处房产。Comments我决定在Comments课堂上创建一个开放属性。
因为我将在 UI 中显示这些内容,并且我希望UserName看到UserID; 以便更好地了解谁发送此评论。
我如何创建以下内容?
public string userName
{
    get
    {
       return //(what I have to write here) 
    }
}