// 2. Using Tuple Tuple<int, string, bool> person = Tuple.Create(1, "John Doe", true); Console.WriteLine($"ID: {person.Item1}, Name: {person.Item2}, Active: {person.Item3}");
// 5. Wait for task result Console.WriteLine(task.Result); } } } net 4.0 framework
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace Net40Example { class Program { static void Main(string[] args) { // 1. Using Task (TPL) - .NET 4.0 Task<string> task = Task.Factory.StartNew(() => { // Simulate work System.Threading.Thread.Sleep(1000); return "Hello from .NET 4.0 Task"; }); // 2. Using Tuple Tuple<
// 3. Using ConcurrentCollection (thread-safe) var concurrentBag = new System.Collections.Concurrent.ConcurrentBag<int>(); concurrentBag.Add(10); concurrentBag.Add(20); person = Tuple.Create(1