I've never really understood this. And I'm sure it holds great value. I just don't understand what.
I was browsing for a code example of something, and that's what this is from. Why so many get/set's ?
I was browsing for a code example of something, and that's what this is from. Why so many get/set's ?
Code:
using System;
/// <summary>
/// Summary description for Person
/// </summary>
public class Person : IPerson
{
private int _ID;
private string _firstname;
private string _lastname;
private bool _isChristian;
public int ID
{
get { return _ID; }
set { _ID = value; }
}
public string Firstname
{
get { return _firstname; }
set { _firstname = value; }
}
public string Lastname
{
get { return _lastname; }
set { _lastname = value; }
}
public bool IsChristian
{
get { return _isChristian; }
set { _isChristian = value; }
}
public Person() {}
public override string ToString()
{
string returnValue = @"ID: " + this.ID.ToString() + "<br />"
+ "Firstname: " + this.Firstname + "<br />"
+ "Lastname: " + this.Lastname + "<br />"
+ "Is Christian: " + this.IsChristian.ToString();
return returnValue;
}
}