/// <summary> /// Converts the term to an <see cref="Int32"/>. /// </summary> /// <param name="term">The term to convert.</param> /// <returns>The resulting value.</returns> /// <exception cref="InvalidCastException"> /// The term could not be converted. /// </exception> public static Int32 ToInt32(this ITerm term) { #region Contract if (term == null) { throw new ArgumentNullException(nameof(term)); } #endregion var result = term.AsInt32(); if (result == null) { throw new InvalidCastException($"Can't cast term {term} to Int32."); } return((Int32)result); }