public class Student { public string name { get; set; } public string sex { get; set; } } public static void Show01() { int r = new Random().Next(3, 4); System.Threading.Thread.Sleep(r * 1000); Console.WriteLine("線程01 不帶參數,不帶返回值"); } public static void Show02(int a,int b) { int r = new Random().Next(3, 4); System.Threading.Thread.Sleep(r * 1000); Console.WriteLine("線程02 帶參數,不帶返回值"); } public static Student Show03(int a, int b) { int r = new Random().Next(3, 4); System.Threading.Thread.Sleep(r * 1000); Console.WriteLine("線程03 帶參數, 帶返回值"); a = b; return new Student() { name="張三", sex="男" }; } static void Main(string[] args) { Task.Run(() => Show01()); Task.Run(() => Show02(1,2)); var s= Task.Run(() => Show03(1, 4)); Console.WriteLine("Hello World!"); Console.WriteLine("姓名:"+s.Result.name+"; 性別:"+s.Result.sex ); Console.ReadLine(); }