Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    EnumerableExtensions Class

    Namespace: Stride.Core.Extensions
    Assembly: Stride.Core.dll
    System.Object → EnumerableExtensions
    Derived from EnumerableExtensions:

    public static class EnumerableExtensions
    Name Description
    Methods
    ForEach<T>(IEnumerable<T>, Action<T>)

    Executes an action for each item of the given enumerable.

    ForEach<T>(IEnumerable, Action<T>)

    Executes an action for each (casted) item of the given enumerable.

    IndexOf<T>(IEnumerable<T>, Func<T, Boolean>)

    An System.Collections.Generic.IEnumerable<T> extension method that searches for the first match and returns its index.

    IsNullOrEmpty(IEnumerable)

    Tells whether a sequence is null or empty.

    LastIndexOf<T>(IEnumerable<T>, Func<T, Boolean>)

    An System.Collections.Generic.IEnumerable<T> extension method that searches for the last match and returns its index.

    NotNull<T>(IEnumerable<T>)

    Filters out null items from the enumerable.

    NotNull<T>(IEnumerable<Nullable<T>>)

    Filters out null items from the enumerable.

    ToHashCode<T>(IEnumerable<T>)

    Calculates a combined hash code for items of the enumerbale.

    | Improve this Doc View Source

    Methods


    ForEach<T>(IEnumerable<T>, Action<T>)

    Executes an action for each item of the given enumerable.

    public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> source

    Input enumerable to work on.

    System.Action<T> action

    Action performed for each item in the enumerable.

    Type Parameters
    Name Description
    T

    Type of the item value in the enumerable.

    Remarks

    This extension method do not yield. It acts just like a foreach statement.


    ForEach<T>(IEnumerable, Action<T>)

    Executes an action for each (casted) item of the given enumerable.

    public static void ForEach<T>(this IEnumerable source, Action<T> action)
    Parameters
    Type Name Description
    System.Collections.IEnumerable source

    Input enumerable to work on.

    System.Action<T> action

    Action performed for each item in the enumerable.

    Type Parameters
    Name Description
    T

    Type of the item value in the enumerable.

    Remarks

    This extension method do not yield. It acts just like a foreach statement, and performs a cast to a typed enumerable in the middle.


    IndexOf<T>(IEnumerable<T>, Func<T, Boolean>)

    An System.Collections.Generic.IEnumerable<T> extension method that searches for the first match and returns its index.

    [Pure]
    public static int IndexOf<T>(this IEnumerable<T> source, Func<T, bool> predicate)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> source

    Input enumerable to work on.

    System.Func<T, System.Boolean> predicate

    The predicate.

    Returns
    Type Description
    System.Int32

    The index of the first element matching.

    Type Parameters
    Name Description
    T

    Generic type parameter.


    IsNullOrEmpty(IEnumerable)

    Tells whether a sequence is null or empty.

    [Pure]
    public static bool IsNullOrEmpty(this IEnumerable source)
    Parameters
    Type Name Description
    System.Collections.IEnumerable source

    The source sequence.

    Returns
    Type Description
    System.Boolean

    Returns true if the sequence is null or empty, false if it is not null and contains at least one element.


    LastIndexOf<T>(IEnumerable<T>, Func<T, Boolean>)

    An System.Collections.Generic.IEnumerable<T> extension method that searches for the last match and returns its index.

    [Pure]
    public static int LastIndexOf<T>(this IEnumerable<T> source, Func<T, bool> predicate)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> source

    Input enumerable to work on.

    System.Func<T, System.Boolean> predicate

    The predicate.

    Returns
    Type Description
    System.Int32

    The index of the last element matching.

    Type Parameters
    Name Description
    T

    Generic type parameter.


    NotNull<T>(IEnumerable<T>)

    Filters out null items from the enumerable.

    [Pure]
    public static IEnumerable<T> NotNull<T>(this IEnumerable<T> source)
        where T : class
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> source

    Input enumerable to work on.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T>

    An enumeration of all items in source that are not null.

    Type Parameters
    Name Description
    T

    Generic type parameter.


    NotNull<T>(IEnumerable<Nullable<T>>)

    Filters out null items from the enumerable.

    [Pure]
    public static IEnumerable<T> NotNull<T>(this IEnumerable<T?> source)
        where T : struct
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.Nullable<T>> source

    Input enumerable to work on.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T>

    An enumeration of all items in source that are not null.

    Type Parameters
    Name Description
    T

    Generic type parameter.


    ToHashCode<T>(IEnumerable<T>)

    Calculates a combined hash code for items of the enumerbale.

    [Pure]
    public static int ToHashCode<T>(this IEnumerable<T> source)
        where T : class
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<T> source

    Input enumerable to work on.

    Returns
    Type Description
    System.Int32

    A combined hash code or 0 if the source is empty.

    Type Parameters
    Name Description
    T

    Generic type parameter.


    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation