对于C#中的字典API? [英] A Dictionary API for C#?

查看:132
本文介绍了对于C#中的字典API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道一个良好的.NET API字典?我不感兴趣的含义,而我需要在许多不同的方式可以查询词 - x长回报的话,返回部分匹配等等...

Does anyone know a good .NET dictionary API? I'm not interested in meanings, rather I need to be able query words in a number of different ways - return words of x length, return partial matches and so on...

感谢

推荐答案

这是一个开放源代码的拼写检查器的aspell一样抢纯文本文件(的http://中的aspell .NET / ),并将其加载到列表或任何结构你喜欢的。

Grab the flat text file from an open source spellchecker like ASpell (http://aspell.net/) and load it into a List or whatever structure you like.

例如,

List<string> words = System.IO.File.ReadAllText("MyWords.txt").Split(new string[]{Environment.NewLine}).ToList();

// C# 3.0 (LINQ) example:

    // get all words of length 5:
    from word in words where word.length==5 select word

    // get partial matches on "foo"
    from word in words where word.Contains("foo") select word

// C# 2.0 example:

    // get all words of length 5:
    words.FindAll(delegate(string s) { return s.Length == 5; });

    // get partial matches on "foo"
    words.FindAll(delegate(string s) { return s.Contains("foo"); });

这篇关于对于C#中的字典API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆