实现IEnumerable以添加IWord对象

时间:2013-06-17 12:26:34

标签: winforms word-cloud

我在C#中下载了cloud control 它使用 IEnumerable 来计算,排序和过滤 我想制作一个方法来帮助我添加 IWord(字符串文本,int occurence)

其他方法

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));



    }

1 个答案:

答案 0 :(得分: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;

    }

我使用此代码而不是我的问题已解决