Showing Full Name using Property

vishalneeraj-24503
Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 1061
Suppose you have a class name,properties are defined as First Name,Middle Name and Last Name.
Using String.Format method
public String FullName
{
get { return String.Format("{0} {1} {2}", class_obj.First_Name.Trim(),class_obj.Middle_Name.Trim(),class_obj.Last_Name.Trim()); }
}


Using + Sign to concatnate
public String FullName
{
get { return class_obj.First_Name.Trim() + ' ' + class_obj.Middle_Name.Trim() + ' ' + class_obj.Last_Name.Trim(); }
}


And assign above property to any controls.

Comments or Responses

Login to post response