c# 分词搜索代码
时间: 2023-07-27 13:23:27 浏览: 61
好的,以下是一个简单的 C# 分词搜索代码示例:
```csharp
using System;
using System.Collections.Generic;
using System.Linq;
namespace TokenSearch
{
class Program
{
static void Main(string[] args)
{
// 定义待搜索的文本
string text = "The quick brown fox jumps over the lazy dog.";
// 将文本分解成单词列表
List<string> words = text.Split(' ').ToList();
// 搜索包含特定单词的单词列表
List<string> matchingWords = words.Where(w => w.Contains("fox")).ToList();
// 输出搜索结果
Console.WriteLine("Matching words:");
foreach (string word in matchingWords)
{
Console.WriteLine(word);
}
}
}
}
```
这个程序将文本 "The quick brown fox jumps over the lazy dog." 分解成单词列表,然后搜索包含 "fox" 的单词,并输出搜索结果。你可以根据你的具体需求修改该程序。