c# - 使用数组查找 .txt 文件中的出现并将值存储在列表框中
问题描述
如何使用数组查找项目的频率并将它们存储在列表框中?
解决方案
您需要阅读文件的文本并将其转换为字符串类型。然后使用
string[] array = yourString.Split(" ");
将文本拆分为单词数组和
int count = 0;
for(int i = 0; i < array.Length; i++){
if (array[i] == "pattern")
count++;
}
推荐阅读
- c - 如何在visual studio c 中打印■?
- javascript - IE 11 无法从 Angular 中的字节数组创建文件对象
- php - 通过 file_get_contents 发送帖子数据,客户端/浏览器可读的帖子数据?
- email - 将密码直接发送到恢复电子邮件而不是密码重置链接
- java - Intellij 将多个 Java 类声明到一个文件中导致奇怪的 UI
- javascript - 如何在js中解构嵌套对象
- postgresql - 创建在我结束事务时自行删除的临时表
- angular - Angular Material Paginator 使用来自前端的数据
- r - Rshiny:单击多边形时显示图表
- shell - 将多个 txt 文件合并到 csv - 添加标题