Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
public class User
 {
     public int userID{ get; set; }
     public string userName{ get; set; }
     public string userPassword { get; set; }
     public string userMail{ get; set; }
}


C#
public class Comments
{
    public int ID { get; set; }
    public int userID{ get; set; }
    public string commentHeader{ get; set; }
    public string commentContent{ get; set; }
}



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

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

1 solution

This is one possible option:
C#
private string m_strUserName;
public string userName
{
  get
  {
    return m_strUserName;
  }
}
 
Share this answer
 
Comments
y.baris 25-Sep-12 7:50am    
can you explain a little please...how can I reach information of user which I only know about his ID.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900