相关疑难解决方法(0)

在C#中搜索简单关键字的ASCII文件的最快方法?

现在,我在ASCII文件中搜索简单的关键字,如下所示:

int SearchInFile (string file, string searchString)
{
    int num = 0;

    StreamReader reader = File.OpenText (file);
    string line = reader.ReadLine();

    while (line != null)
    {
        int count = CountSubstrings(line, searchString);
        if (count != 0)
        {
            num += count;
        }
        line = reader.ReadLine();
    }

    reader.Close();

    return num;
}
Run Code Online (Sandbox Code Playgroud)

这是最快,最有效的内存方式吗?返回计数是可选的,如果它将在搜索方式上产生巨大差异,但不是单独的.

我用它像:

SearchInFile ( "C:\\text.txt", "cool" );
Run Code Online (Sandbox Code Playgroud)

.net c# io performance

2
推荐指数
1
解决办法
2634
查看次数

标签 统计

.net ×1

c# ×1

io ×1

performance ×1