小编mlo*_*ske的帖子

c#ListView.Items [i] .remove非常慢

这是我第一次来这里,我正在努力解决这个问题.我有这段代码:

try
{
    progressBar1.Maximum = lista.Items.Count;
    lista.BeginUpdate();

    for (int i = 0; lista.Items.Count > i; i++)

    //for (int i = lista.Items.Count - 1; -1 < i; i--)
    {
        if (lista.Items[i].SubItems[1].Text.ToLower().Contains(Text) == false)
        {                        
            lista.Items[i].Remove();                        
        }

        progressBar1.Value = progressBar1.Value + 1;
    }

    lista.EndUpdate();

    progressBar1.Value = 0;
}
catch (Exception errore)
{
    txt_info.Text = "" + errore.Message;
    progressBar1.Value = 0;
}
Run Code Online (Sandbox Code Playgroud)

该方法lista.items[i].remove非常慢. lista是一个ListView,我正在处理一个大于50,000行的日志文件.反正是为了加快这个过程吗?

c# listview

6
推荐指数
1
解决办法
1622
查看次数

十进制数的正则表达式(最多3位十进制数字,带逗号)

如何编写一个正则表达式来验证应该只包含十进制值的输入文本框?该值可以包含最多3位小数(但也没有),逗号作为分隔符.

例如,下面给出的这些值是有效的: -

1,234
1,23
1,2
1

这些无效:

1,2345 (too many decimal numbers)
A (a letter is not a number)
  (a space or string empty)
1.234 (used a dot instead of a comma)

c# regex

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

标签 统计

c# ×2

listview ×1

regex ×1