I would suggest an explicit Set method:
private int _currentPage; public int CurrentPage { get { return _currentPage; } } public void SetCurrentPage(string value) { _currentPage = (string.IsNullOrEmpty(value)) ? 1 : Convert.ToInt32(value); }
As a side note, your parsing method might look like this:
if (!int.TryParse(value, out _currentPage) { _currentPage = 1; }
This avoids formatting exceptions.
John gietzen
source share