public static int EndYear(this King king) { var yr = king.Years.Split('-'); // If the reign did not finish yet if (yr.Length > 1 && yr[1] == "") { return(DateTime.Now.Year); } // Normal case - Started one year, finished another if (yr.Length > 1 && yr[1] != "") { return(Convert.ToInt32(yr[1])); } // Year that ended was the same as the one that started return(king.StartYear()); }
public static int RuledFor(this King king) { return(king.EndYear() - king.StartYear()); }