コード例 #1
0
        /// <summary>
        /// 数组子串
        /// </summary>
        /// <param name="array"></param>
        /// <param name="startIndex"></param>
        /// <param name="length"></param>
        public SubArray(valueType[] array, int startIndex, int length)
        {
            FormatRange range = new FormatRange(array.length(), startIndex, length);

            Array  = array;
            Start  = range.SkipCount;
            Length = range.GetCount;
        }
コード例 #2
0
ファイル: SubString.AutoCSer.cs プロジェクト: mmarzz/AutoCSer
        /// <summary>
        /// 字符子串
        /// </summary>
        /// <param name="value">字符串</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="length">长度</param>
        public SubString(string value, int startIndex, int length)
        {
            FormatRange range = new FormatRange(value.Length, startIndex, length);

            if (range.GetCount != length)
            {
                throw new IndexOutOfRangeException();
            }
            String = value;
            Start  = range.SkipCount;
            Length = length;
        }
コード例 #3
0
ファイル: ListArray.cs プロジェクト: zhangzheng1205/AutoCSer
        /// <summary>
        /// 添加数据集合
        /// </summary>
        /// <param name="values">数据集合</param>
        /// <param name="index">起始位置</param>
        /// <param name="count">数量</param>
        public override void Add(valueType[] values, int index, int count)
        {
            FormatRange range = new FormatRange(values.length(), index, count);

            if ((count = range.GetCount) != 0)
            {
                int newLength = Length + count;
                addToLength(newLength);
                System.Array.Copy(values, range.SkipCount, Array, Length, count);
                Length = newLength;
            }
        }
コード例 #4
0
        /// <summary>
        /// 获取子串
        /// </summary>
        /// <param name="startIndex"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public SubArray <valueType> GetSub(int startIndex, int length)
        {
            FormatRange range = new FormatRange(Length, startIndex, length);

            if (range.GetCount != length)
            {
                throw new IndexOutOfRangeException("startIndex[" + startIndex.toString() + "] + length[" + length.toString() + "] > Length[" + Length.toString() + "]");
            }
            SubArray <valueType> value = default(SubArray <valueType>);

            value.Set(Array, Start + startIndex, length);
            return(value);
        }