StringSegment Structure

Represents a segment of a string. This type is similar to ReadOnlyMemory<char>/ReadOnlySpan<char> but StringSegment can be used on all platforms in the same way and is optimized for some dedicated string operations.
To create an instance use the AsSegment extension method overloads or just cast a string instance to StringSegment.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
[SerializableAttribute]
[TypeConverterAttribute(typeof(StringSegmentConverter))]
public readonly struct StringSegment : IEquatable<StringSegment>, 
	IComparable<StringSegment>, IComparable, IReadOnlyList<char>, IEnumerable<char>, 
	IEnumerable, IReadOnlyCollection<char>
Inheritance
Object    ValueType    StringSegment
Implements
IEnumerableChar, IReadOnlyCollectionChar, IReadOnlyListChar, IEnumerable, IComparable, IComparableStringSegment, IEquatableStringSegment

Remarks

To create a StringSegment instance from a string you can use the implicit conversion, or the AsSegment extension methods.

To convert a StringSegment instance to string use an explicit cast or the ToString method.

  Note

The StringSegment type may outperform string in scenarios when usual string splitting/trimming operations would allocate long strings.
See a live example with performance test here.

Depending on the used platform some members of the StringSegment type may allocate a new string. The affected members are:

  Note

On .NET Core 3.0 and newer platforms none of the members above allocate a new string. On .NET Standard 2.1/.NET Core 2.1 and newer platforms the IndexOf overloads are not affected.

As opposed to the String class, the default comparison strategy in StringSegment members is Ordinal.

Examples

The following example demonstrates how to use the StringSegment type:

C#
using System;
using KGySoft.CoreLibraries;

class Example
{
    public static void Main()
    {
        // Assignment works from string
        StringSegment segment = "Some string literal";

        // Or by extension methods:
        segment = "Some string literal".AsSegment(); // "Some string literal"
        segment = "Some string literal".AsSegment(0, 4); // "Some"
        segment = "Some string literal".AsSegment(5, 6); // "string"

        // Null assignment: all the following lines have the same effect:
        segment = default(StringSegment); // the fastest way
        segment = StringSegment.Null; // the recommended way
        segment = null; // the cleanest way - same as segment = ((string)null).AsSegment()

        // Null check (remember, StringSegment is a value type with null semantics):
        bool isNull = segment == null; // the cleanest way - same as segment.Equals(((string)null).AsSegment())
        isNull = segment.IsNull; // the fastest and recommended way - same as segment.UnderlyingString == null

        // Slicing:
        segment = "Some string literal";
        Console.WriteLine(segment.Substring(0, 4)); // "Some"
        Console.WriteLine(segment.Substring(5)); // "string literal"
        Console.WriteLine(segment.Split(' ').Count); // 3
        Console.WriteLine(segment.Split(' ')[2]); // "literal"

        // Slicing operations do not allocate new strings:
        StringSegment subsegment = segment.Substring(5);
        subsegment = segment[5..]; // Range indexer is also supported
        Console.WriteLine(subsegment); // "string literal"
        Console.WriteLine(subsegment.UnderlyingString); // "Some string literal"

        // As StringSegment can be implicitly converted to ReadOnlySpan<char> it can be passed
        // to many already existing API accepting spans (in .NET Core 2.1/.NET Standard 2.1 and above):
        int parsedResult = Int32.Parse("Value=42".AsSegment().Split('=')[1]);
    }
}

The following example demonstrates a possible usage of the StringSegment type:

  Tip

Try the extended example with performance comparison online.
C#
/**************************************************************
 * This example retrieves values from multiline text like this:
 * Key1=Value1;Value2
 * Key2=SingleValue
 * See a working example here: https://dotnetfiddle.net/Byk0YM
 **************************************************************/
// The original way:
public static string[] ByString(string content, string key)
{
    // getting all lines, filtering the first empty line
    string[] nonEmptyLines = content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

    foreach (string line in nonEmptyLines)
    {
        // Separating key from values. We can use count: 2 because we split at the first '=' only.
        string[] keyValues = line.Split(new[] { '=' }, count: 2);

        // Removing white spaces and returning values if the key matches
        if (keyValues[0].TrimStart() == key)
            return keyValues[1].Split(';');
    }

    // key not found
    return null;
}

// The StringSegment way: almost the same code as above
public static IList<StringSegment> ByStringSegment(string content, string key)
{
    // getting all lines, filtering the first empty line
    IList<StringSegment> nonEmptyLines = content.AsSegment().Split(Environment.NewLine, removeEmptyEntries: true);

    foreach (StringSegment line in nonEmptyLines)
    {
        // Separating key from values. We can use maxLength: 2 because we split at the first '=' only.
        IList<StringSegment> keyValues = line.Split('=', maxLength: 2);

        // Removing white spaces and returning values if the key matches
        if (keyValues[0].TrimStart() == key)
            return keyValues[1].Split(';');
    }

    // key not found
    return null;
}

// An alternative StringSegment way: uses Split only if we need all segments or we can limit max counts.
public static IList<StringSegment> ByStringSegmentAlternative(string content, string key)
{
    StringSegment rest = content; // same as content.AsSegment()
    while (!rest.IsNull)
    {
        // Advancing to the next line (StringSegment is immutable but the extension uses ref this parameter)
        StringSegment line = rest.ReadLine(); // or ReadToSeparator(Environment.NewLine, "\r", "\n")
        if (line.Length == 0)
            continue;

        // Separating key from values. We can use maxLength: 2 because we split at the first '=' only.
        IList<StringSegment> keyValues = line.Split('=', maxLength: 2);

        // Removing white spaces and returning values if the key matches
        if (keyValues[0].TrimStart() == key)
            return keyValues[1].Split(';');
    }

    // key not found
    return null;
}

Properties

AsMemory Returns the current StringSegment instance as a ReadOnlyMemoryT of characters.
AsSpan Returns the current StringSegment instance as a ReadOnlySpanT of characters.
IsNull Gets whether this StringSegment instance was created from a  string.
Please note that the ToString method returns when this property returns .
IsNullOrEmpty Gets whether this StringSegment instance represents an empty segment or was created from a  string.
IsNullOrWhiteSpace Gets whether this StringSegment instance represents a or empty string, or contains only whitespace characters.
ItemInt32 Gets the character at the specified position in this StringSegment.
ItemRange Gets the StringSegment from this instance that represents the substring of the specified range.
Length Gets the length of this StringSegment.
Offset Gets the offset, which denotes the start position of this StringSegment within the UnderlyingString.
UnderlyingString Gets the underlying string of this StringSegment.

Methods

Compare(StringSegment, StringSegment, StringComparison) Compares two specified StringSegment instances using the specified comparison, and returns an integer that indicates their relative position in the sort order.
Compare(StringSegment, StringSegment, Boolean, CultureInfo) Compares two specified StringSegment instances, ignoring or honoring their case, and using the specified culture, and returns an integer that indicates their relative position in the sort order.
CompareTo(Object) Compares this instance to the specified object using ordinal comparison, and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified StringSegment.
CompareTo(StringSegment) Compares this instance to the specified StringSegment using ordinal comparison, and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified StringSegment.
EndsWith(Char) Gets whether this StringSegment instance ends with the specified value.
EndsWith(ReadOnlySpanChar, StringComparison) Gets whether this StringSegment instance ends with the specified value using the specified comparison.
EndsWith(StringSegment, StringComparison) Gets whether this StringSegment instance ends with the specified value using the specified comparison.
Equals(Object) Determines whether the specified object is equal to this instance.
(Overrides ValueTypeEquals(Object))
Equals(String) Indicates whether the current StringSegment instance is equal to another one specified in the other parameter.
Equals(StringSegment) Indicates whether the current StringSegment instance is equal to another one specified in the other parameter.
Equals(StringSegment, StringSegment, StringComparison) Determines whether two specified StringSegment instances have the same value using the specified comparison.
GetEnumerator Returns an enumerator that iterates through the StringSegment characters.
GetHashCode Returns a hash code for this StringSegment instance.
(Overrides ValueTypeGetHashCode)
GetHashCode(StringComparison) Returns the hash code for this StringSegment using the specified comparison.
IndexOf(Char) Gets the zero-based index of the first occurrence of the specified value in this StringSegment.
IndexOf(ReadOnlySpanChar) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using ordinal comparison.
IndexOf(String) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using ordinal comparison.
IndexOf(StringSegment) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using ordinal comparison.
IndexOf(Char, Int32) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified startIndex.
IndexOf(ReadOnlySpanChar, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified comparison.
IndexOf(String, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified comparison.
IndexOf(StringSegment, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified comparison.
IndexOf(Char, Int32, Int32) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified startIndex and count values.
IndexOf(ReadOnlySpanChar, Int32, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified startIndex and comparison.
IndexOf(String, Int32, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified startIndex and comparison.
IndexOf(StringSegment, Int32, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified startIndex and comparison.
IndexOf(ReadOnlySpanChar, Int32, Int32, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified startIndex, count and comparison.
IndexOf(String, Int32, Int32, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified startIndex, count and comparison.
IndexOf(StringSegment, Int32, Int32, StringComparison) Gets the zero-based index of the first occurrence of the specified value in this StringSegment using the specified startIndex, count and comparison.
IndexOfAny(Char) Gets the zero-based index of the first occurrence in this StringSegment of any character in the specified array.
IndexOfAny(Char, Int32) Gets the zero-based index of the first occurrence in this StringSegment of any character in the specified array using the specified startIndex.
IndexOfAny(Char, Int32, Int32) Gets the zero-based index of the first occurrence in this StringSegment of any character in the specified array using the specified startIndex and count values.
LastIndexOf(Char) Gets the zero-based index of the last occurrence of the specified value in this StringSegment.
LastIndexOf(Char, Int32) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex.
LastIndexOf(ReadOnlySpanChar, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified comparison.
LastIndexOf(String, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified comparison.
LastIndexOf(StringSegment, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified comparison.
LastIndexOf(Char, Int32, Int32) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex and count values.
LastIndexOf(ReadOnlySpanChar, Int32, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex and comparison.
LastIndexOf(String, Int32, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex and comparison.
LastIndexOf(StringSegment, Int32, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex and comparison.
LastIndexOf(ReadOnlySpanChar, Int32, Int32, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex, count and comparison.
LastIndexOf(String, Int32, Int32, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex, count and comparison.
LastIndexOf(StringSegment, Int32, Int32, StringComparison) Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex, count and comparison.
LastIndexOfAny(Char) Gets the zero-based index of the last occurrence in this StringSegment of any character in the specified array.
LastIndexOfAny(Char, Int32) Gets the zero-based index of the last occurrence in this StringSegment of any character in the specified array using the specified startIndex.
LastIndexOfAny(Char, Int32, Int32) Gets the zero-based index of the last occurrence in this StringSegment of any character in the specified array using the specified startIndex and count values.
Split(Char) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, Char) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(String) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, String) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(StringSegment) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, StringSegment) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. This overload uses the whitespace characters as separators. Alternatively, you can use the ReadToWhiteSpace extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(Char, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, Char) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(Char, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, Char) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(NullableInt32, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances of no more than maxLength segments, without allocating new strings. This overload uses the whitespace characters as separators. Alternatively, you can use the ReadToWhiteSpace extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(ReadOnlySpanChar, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, ReadOnlySpanChar) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(String, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, String) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(String, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, String) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(StringSegment, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, StringSegment) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(StringSegment, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, StringSegment) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(Char, NullableInt32, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances of no more than maxLength segments, without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, Char) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(Char, NullableInt32, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances of no more than maxLength segments, without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, Char) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(ReadOnlySpanChar, NullableInt32, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances of no more than maxLength segments, without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, ReadOnlySpanChar) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(String, NullableInt32, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances of no more than maxLength segments, without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, String) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(String, NullableInt32, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances of no more than maxLength segments, without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, String) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(StringSegment, NullableInt32, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances of no more than maxLength segments, without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, StringSegment) extension method.
See the Remarks section of the StringSegment type for details and some examples.
Split(StringSegment, NullableInt32, StringSegmentSplitOptions) Splits this StringSegment instance into a collection of StringSegment instances of no more than maxLength segments, without allocating new strings. Alternatively, you can use the ReadToSeparator(StringSegment, StringSegment) extension method.
See the Remarks section of the StringSegment type for details and some examples.
StartsWith(Char) Gets whether this StringSegment instance starts with the specified value.
StartsWith(ReadOnlySpanChar, StringComparison) Gets whether this StringSegment instance starts with the specified value using the specified comparison.
StartsWith(String, StringComparison) Gets whether this StringSegment instance starts with the specified value using the specified comparison.
StartsWith(StringSegment, StringComparison) Gets whether this StringSegment instance starts with the specified value using the specified comparison.
Substring(Int32) Gets a new StringSegment instance, which represents a substring of the current instance with the specified startIndex.
Substring(Int32, Int32) Gets a StringSegment instance, which represents a substring of the current instance with the specified startIndex and length.
ToString Gets a string that is represented by this StringSegment instance, or , if this instance represents a  string. That is, when the IsNull property returns .
(Overrides ValueTypeToString)
Trim Removes all leading and trailing white-space characters from the current StringSegment.
Trim(Char) Removes all leading and trailing instances of a character from the current StringSegment.
Trim(Char) Removes all leading and trailing occurrences of a set of characters specified in an array from the current StringSegment.
Trim(ReadOnlySpanChar) Removes all leading and trailing occurrences of a set of characters specified in an array from the current StringSegment.
TrimEnd Removes all the trailing white-space characters from the current StringSegment.
TrimEnd(Char) Removes all trailing instances of a character from the current StringSegment.
TrimEnd(Char) Removes all trailing occurrences of a set of characters specified in an array from the current StringSegment.
TrimEnd(ReadOnlySpanChar) Removes all trailing occurrences of a set of characters specified in an array from the current StringSegment.
TrimStart Removes all the leading white-space characters from the current StringSegment.
TrimStart(Char) Removes all leading instances of a character from the current StringSegment.
TrimStart(Char) Removes all leading occurrences of a set of characters specified in an array from the current StringSegment.
TrimStart(ReadOnlySpanChar) Removes all leading occurrences of a set of characters specified in an array from the current StringSegment.

Operators

Equality(StringSegment, StringSegment) Determines whether two specified StringSegment instances have the same value.
(StringSegment to String) Performs an explicit conversion from StringSegment to string.
(String to StringSegment) Performs an implicit conversion from string to StringSegment.
(StringSegment to ReadOnlySpanChar) Performs an implicit conversion from StringSegment to ReadOnlySpan<char>.
Inequality(StringSegment, StringSegment) Determines whether two specified StringSegment instances have different values.

Fields

Empty Represents the empty StringSegment. This field is read-only.
Null Represents the  StringSegment. This field is read-only.

Extension Methods

Convert Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions)
ConvertTTarget Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions)
ForEachChar Similarly to the List<T>.ForEach method, processes an action on each element of an enumerable collection.
(Defined by EnumerableExtensions)
GetRandomElementChar Gets a random element from the enumerable source using a new FastRandom instance.
(Defined by EnumerableExtensions)
GetRandomElementChar Gets a random element from the enumerable source using a specified Random instance.
(Defined by EnumerableExtensions)
In Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example.
(Defined by ObjectExtensions)
IndexOf Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IndexOf Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
IndexOfChar Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
IndexOfChar Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IsNullOrEmpty Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
IsNullOrEmptyChar Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
JoinChar Concatenates the items of the source collection into a new string instance using the specified separator between the items.
(Defined by EnumerableExtensions)
JoinChar Concatenates the items of the source collection into a new string instance using the specified separator between the items.
(Defined by EnumerableExtensions)
Read Advances the specified rest parameter consuming up to maxLength characters and returns the consumed part. If rest started with a new line before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadLine Advances the specified rest parameter after the current line and returns the consumed part without the newline character(s). If rest started with a new line before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadToSeparator Advances the specified rest parameter after the next separator character and returns the consumed part without the separator. If the first character of rest was a separator before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadToSeparator Advances the specified rest parameter after the next separator and returns the consumed part without the separator. If rest started with one of the separators before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadToSeparator Advances the specified rest parameter after the next separator and returns the consumed part without the separator. If rest started with separator before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadToSeparator Advances the specified rest parameter after the next separator and returns the consumed part without the separator. If rest started with separator before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadToSeparator Advances the specified rest parameter after the next separator and returns the consumed part without the separator. If rest started with one of the separators before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadToSeparator Advances the specified rest parameter after the next separator and returns the consumed part without the separator. If rest started with separator before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadToSeparator Advances the specified rest parameter after the next separator and returns the consumed part without the separator. If rest started with one of the separators before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
ReadToWhiteSpace Advances the specified rest parameter after the next whitespace character and returns the consumed part without the whitespace. If the first character of rest was a whitespace before the call, then an empty segment is returned. If the whole StringSegment has been processed, then rest will be StringSegment.Null after returning.
(Defined by StringSegmentExtensions)
RemoveQuotes Extracts content of a single or double quoted string.
(Defined by StringSegmentExtensions)
ShuffleChar Shuffles an enumerable source (randomizes its elements) using a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleChar Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleChar Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleChar Shuffles an enumerable source (randomizes its elements) using a specified Random instance.
(Defined by EnumerableExtensions)
ToCircularListChar Creates a CircularListT from an IEnumerableT.
(Defined by EnumerableExtensions)
ToEnumTEnum Tries to convert the specified StringSegment to an Enum value of TEnum type. No string allocation occurs when using this method.
(Defined by StringSegmentExtensions)
ToStringKeyedDictionaryChar Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified keySelector delegate and a comparer.
(Defined by EnumerableExtensions)
ToStringKeyedDictionaryChar, TValue Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified key and value selector delegates and a comparer.
(Defined by EnumerableExtensions)
TryAdd Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddChar Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddRange Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryAddRangeChar Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryClear Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
TryClearChar Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryGetCount Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetCountChar Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetElementAt Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryGetElementAtChar Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryInsert Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertChar Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertRange Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryInsertRangeChar Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryRemove Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveChar Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveAt Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveAtChar Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveRange Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryRemoveRangeChar Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryReplaceRange Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions)
TryReplaceRangeChar Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions)
TrySetElementAt Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)
TrySetElementAtChar Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)

See Also