Ejemplo n.º 1
0
        /// <summary>
        /// 尝试从字符串中获取区间
        /// </summary>
        /// <param name="str"></param>
        /// <param name="intervalDoublePair"></param>
        /// <param name="force">若是能转为double但无法转为区间,强制转换为区间(即left=right值)</param>
        /// <returns></returns>
        public static bool TryGetIntervalDoublePair(string str, out IntervalDoublePair intervalDoublePair, bool force = false)
        {
            if (IntervalDouble.GetInterval(str, out IntervalDouble left, out IntervalDouble right, force))
            {
                intervalDoublePair = new IntervalDoublePair(left, right);
                return(true);
            }

            intervalDoublePair = default;
            return(false);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 判断给定区间是否在本区间中(包含)
 /// </summary>
 /// <param name="interval"></param>
 /// <returns></returns>
 public bool IsInInterval(IntervalDoublePair interval) =>
 LeftInterval <= interval.LeftInterval && RightInterval >= interval.RightInterval;