WordList.Add 方法 (String)

将一个字符串添加到 WordList 对象中。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Sub Add ( _
    s As String _
)
用法
Dim instance As WordList
Dim s As String

instance.Add(s)
public void Add(
    string s
)
public:
void Add(
    String^ s
)
public void Add(
    String s
)
public function Add(
    s : String
)

参数

备注

如果传入 s 参数的字符串在 WordList 对象中已经存在,则不添加该字符串。

如果将某个字符串添加到单词列表中,同时也会隐式添加该字符串的大写版本。例如,添加“hello”时将隐式添加“Hello”和“HELLO”。

WordList 对象可包含表示单词、短语或部件号的字符串,以及用户可以书写、但不在系统字典 中的任何其他字符串。

WordList 中的单词的大小限制是 256 个字符。如果使用长度超过 256 个字符的单词,则向 RecognizerContext 分配 WordList 时将引发无效指针异常。

示例

在此示例中,将创建两个 WordList 对象并向其集合添加单词。使用 Merge 方法合并两个 WordList 对象的内容。最后,实例化一个 RecognizerContext 对象,并将第一个 WordList 对象分配给它的 WordList 属性。

Dim wList1 As WordList = New WordList()
Dim wList2 As WordList = New WordList()
' add a single word to wList1
wList1.Add("thunk")
' add an array of words to wList2
Dim words() As String = {"Microsoft", "Tablet", "PC"}
wList2.Add(words)
' merge wList2 into wList1
wList1.Merge(wList2)
' create a new RecognizerContext object and assign wList1
Dim RC As RecognizerContext = New RecognizerContext()
RC.WordList = wList1
WordList wList1 = new WordList();
WordList wList2 = new WordList();
// add a single word to wList1
wList1.Add("thunk");
// add an array of words to wList2
string[] words = { "Microsoft", "Tablet", "PC" };
wList2.Add(words);
// merge wList2 into wList1
wList1.Merge(wList2);
// create a new RecognizerContext object and assign wList1
RecognizerContext RC = new RecognizerContext();
RC.WordList = wList1;

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

WordList 类

WordList 成员

Add 重载

Microsoft.Ink 命名空间

RecognizerContext

WordList.Remove