1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
|
class Program
{
public void summe (object obj) //object als einziges Funktionsargument, Rückgabetyp ist void
{
int[] input = (int[])obj; //unboxing
int a = input [0];
int b = input [1];
int sum = Enumerable.Range (a, b - a + 1).Sum ();
Console.WriteLine (sum);
}
static void Main (string[] args)
{
Program addiere = new Program ();
ParameterizedThreadStart threadStart = new ParameterizedThreadStart (addiere.summe);
Thread t1 = new Thread (threadStart) { Name = "t1" };
t1.Start (new int[] { 0, 50 });
}
} |