课堂上的新开放式财产 [英] new open property in class

查看:84
本文介绍了课堂上的新开放式财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好;
我正在尝试做博客项目,并且正在使用ado.net,并且我具有3层体系结构...
在一个类库中,我有一些属性...例如用户和注释

Hi everyone;
I am trying to do blog project and I am using ado.net and I have 3-tier architecture...
in one of classlibrary I have properties ... such as User and 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; }
}




我想在Comment类中使用userName.我决定在Comment类中创建open属性.
因为我将在用户界面中显示,但我不想仅看到userID;更好地了解了谁使用userName发送了此评论...如何创建




I want use userName in Comments class.And I decided to create open property in Comment class.
Cause I will show in UI and I dont want to see just userID; better for understanding who sent this comment with userName...How I can create

public string userName
{
    get
    {
       return //(what I have to write here)
    }
}

推荐答案

这是一种可能的选择:
This is one possible option:
private string m_strUserName;
public string userName
{
  get
  {
    return m_strUserName;
  }
}


这篇关于课堂上的新开放式财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆