小编plo*_*tic的帖子

无法将类型'int'隐式转换为'... Tasks <int>'

如果这是异步的,它将返回没有错误,为什么它在没有异步的情况下抛出错误,async在这个操作中毫无价值.

public Task<int> countUp()
{
    string compare = txtTag.Text;
    int count = 0;
    for (int i = 0; i < dataGridView1.Rows.Count; i++)
    {
        if (compare == dataGridView1[0, i].Value.ToString())
        {
            BeginInvoke(new Action(() =>
            {
                count++;
                txtCount.Text = count.ToString();
            }));
        }
    }

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

c# task

7
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×1

task ×1