I got the error on var ts = System.Threading.ThreadStart(delegate() (Red line has drown under System.Threading.ThreadStart). What is the problem?
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();
}
}
}
You are missing a
new:BTW:
You don’t have to prefix
ThreadStartwith its namespaceSystem.Threading, because you already have ausingdeclaration for it at the top of your *.cs file.