0

我在 C# 中下载了一个云控件,它使用IEnumerable来计数、排序和过滤我想创建一个方法来帮助我添加IWord(字符串文本,int 出现)

其他方法是

public static IEnumerable<IWord> CountOccurences(this IEnumerable<string> terms)
    {
        return 
            terms.GroupBy(
                term => term,
                (term, equivalentTerms) => new Word(term, equivalentTerms.Count()), 
                StringComparer.InvariantCultureIgnoreCase)
                .Cast<IWord>();
    }
public static IEnumerable<string> Filter(this IEnumerable<string> terms, IBlacklist blacklist)
    {
        return
            terms.Where(
                term => !blacklist.Countains(term));



    }
4

1 回答 1

0
public static IEnumerable<IWord> AddOwnItems(this IEnumerable<string> terms)
    {
        IEnumerable<IWord> obj = new List<IWord>()
        {
          new Word("Development", 12), new Word("Extractor", 24), new Word("Anyother", 18)
        ,new Word("wao", 12),new Word("yours", 18),new Word("how does", 28),new Word("coudnt", 20),new Word("adkj", 22),
        new Word("own", 12),new Word("items", 10),new Word("terms ", 14),new Word("whats", 12),new Word("uupp", 16),
        new Word("Zar E Ahmer", 36),new Word("Cool", 26),new Word("Yhoo", 18),new Word("I am", 14),new Word("never", 16),
        new Word("thirty May", 12),new Word("string", 10),new Word("nothing", 14),new Word("much", 12),new Word("Disney", 16)
        };
        return obj;

    }

我使用这个代码比我的问题解决了

于 2013-06-24T09:28:48.643 回答