コード例 #1
0
        /// <summary>
        /// Returns this sequence as an enumerable collection of lines.
        /// </summary>
        /// <param name="lineLength">The maximum length of each line. If omitted, this is <see cref="Constants.DefaultLineLength"/>.</param>
        /// <returns>This sequence as an enumerable collection of lines.</returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="lineLength"/> is less than one.
        /// </exception>
        /// <seealso cref="ToMultilineString(int)"/>
        public IEnumerable <string> ToLines(int lineLength = Constants.DefaultLineLength)
        {
            if (lineLength < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(lineLength), lineLength, SequenceUtility.ArgumentOutOfRangeException_LineLengthLessThanOne);
            }

            return(SequenceUtility.ToLines(Characters, lineLength));
        }
コード例 #2
0
        /// <summary>
        /// Returns a multiline string representation of this sequence.
        /// </summary>
        /// <param name="lineLength">The maximum length of each line. If omitted, this is <see cref="Constants.DefaultLineLength"/>.</param>
        /// <returns>A multiline string representation of this sequence.</returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="lineLength"/> is less than one.
        /// </exception>
        /// <seealso cref="ToLines(int)"/>
        /// <seealso cref="ToString"/>
        public string ToMultilineString(int lineLength = Constants.DefaultLineLength)
        {
            if (lineLength < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(lineLength), lineLength, SequenceUtility.ArgumentOutOfRangeException_LineLengthLessThanOne);
            }

            if (lineLength == 1)
            {
                return(ToString());
            }

            return(string.Join(Environment.NewLine, SequenceUtility.ToLines(Characters, lineLength)));
        }