Show / Hide Table of Contents

    Class ICollectionsExtensions

    ICollections 扩展方法

    Inheritance
    Object
    ICollectionsExtensions
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Lett.Extensions
    Assembly: Lett.Extensions.dll
    Syntax
    public static class ICollectionsExtensions

    Methods

    | Improve this Doc View Source

    AddIfNotContains<T>(ICollection<T>, T)

    如果不包含,则添加

    Declaration
    public static void AddIfNotContains<T>(this ICollection<T> this, T item)
    Parameters
    Type Name Description
    ICollection<T> this
    T item

    匹配项

    Type Parameters
    Name Description
    T

    集合中元素的类型

    Examples
    var list = new List<string> {"aa", "bb"};
    list.AddIfNotContains("cc");
    list.AddIfNotContains("aa");
    // {"aa", "bb", "cc"}
    Exceptions
    Type Condition
    NotSupportedException

    this maybe is read-only

    | Improve this Doc View Source

    AddIfNotContains<T>(ICollection<T>, IEnumerable<T>)

    如果不包含,则添加

    Declaration
    public static void AddIfNotContains<T>(this ICollection<T> this, IEnumerable<T> items)
    Parameters
    Type Name Description
    ICollection<T> this
    IEnumerable<T> items

    匹配项集合

    Type Parameters
    Name Description
    T

    集合中元素的类型

    Examples
    var list = new List<string> {"aa", "bb"};
    var appendList = new[] {"cc", "aa"};
    list.AddIfNotContains(appendList);
    // {"aa", "bb", "cc"}
    Exceptions
    Type Condition
    NotSupportedException

    this maybe is read-only

    | Improve this Doc View Source

    AddIfNotContainsParams<T>(ICollection<T>, T[])

    如果不包含,则添加

    Declaration
    public static void AddIfNotContainsParams<T>(this ICollection<T> this, params T[] items)
    Parameters
    Type Name Description
    ICollection<T> this
    T[] items

    匹配项集合

    Type Parameters
    Name Description
    T

    集合中元素的类型

    Examples
    var list = new List<string> {"aa", "bb"};
    list.AddIfNotContains("cc", "aa");
    // {"aa", "bb", "cc"}
    Exceptions
    Type Condition
    NotSupportedException

    this maybe is read-only

    | Improve this Doc View Source

    AddRange<T>(ICollection<T>, IEnumerable<T>)

    批量添加

    Declaration
    public static void AddRange<T>(this ICollection<T> this, IEnumerable<T> items)
    Parameters
    Type Name Description
    ICollection<T> this
    IEnumerable<T> items
    Type Parameters
    Name Description
    T
    Examples
    var list       = new List<string> {"aa", "bb"};
    var appendList = new List<string> {"cc", "aa"};
    list.AddRange(appendList);
    // {"aa", "bb", "cc", "aa"}
    Exceptions
    Type Condition
    NotSupportedException

    this maybe is read-only

    ArgumentNullException

    this

    | Improve this Doc View Source

    AddRangeParams<T>(ICollection<T>, T[])

    批量添加

    Declaration
    public static void AddRangeParams<T>(this ICollection<T> this, params T[] items)
    Parameters
    Type Name Description
    ICollection<T> this
    T[] items
    Type Parameters
    Name Description
    T
    Examples
    var list       = new List<string> {"aa", "bb"};
    list.AddRange("cc", "aa");
    // {"aa", "bb", "cc", "aa"}
    Exceptions
    Type Condition
    NotSupportedException

    this maybe is read-only

    • Improve this Doc
    • View Source
    Back to top Copyright (c) 2019 viacooky. All rights reserved.