以下の内容はhttps://baba-s.hatenablog.com/entry/2020/03/19/025000より取得しました。


【C#】シーケンスから重複している要素を取得する拡張メソッド

ソースコード

using System;
using System.Collections.Generic;
using System.Linq;

public static class IEnumerableExt
{
    public static IEnumerable<TKey> GetDuplication<TKey, TSource>
    (
        this IEnumerable<TSource> self,
        Func<TSource, TKey>       keySelector
    )
    {
        return self
                .GroupBy( keySelector )
                .Where( c => 1 < c.Count() )
                .Select( c => c.Key )
            ;
    }
}

使用例

var names = list.GetDuplication( c => c.name );

foreach ( var name in names )
{
    Debug.Log( name );
}



以上の内容はhttps://baba-s.hatenablog.com/entry/2020/03/19/025000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14