【发布时间】:2012-12-16 12:51:36
【问题描述】:
我在var ts = System.Threading.ThreadStart(delegate() 上收到错误消息(红线已淹没在System.Threading.ThreadStart 下)。问题是什么?
using System;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public Program()
{
int[] iArray = new int[3];
iArray[0] = 2;
iArray[1] = 1;
iArray[2] = 5;
var ts = System.Threading.ThreadStart(delegate()
{
foreach (int i in iArray)
Foo(i);
});
}
public void Foo(int i)
{
Console.WriteLine(i + ",");
}
public static void Main(String[] args)
{
Program p = new Program();
}
}
}
【问题讨论】:
标签: c# .net multithreading delegates lambda