Enabled data and task parallelism without manual thread management. 3.2 Parallel LINQ (PLINQ) Queries automatically parallelized:
| Workload | Improvement over .NET 3.5 | |----------|----------------------------| | Parallel.For (4 cores) | 3.8x speedup | | Background GC (UI apps) | 40% fewer UI stutters | | LOH allocations | 15% lower fragmentation | | Startup time (NGEN) | 20% faster | net framework 4.0 3019
public int Divide(int numerator, int denominator) Enabled data and task parallelism without manual thread
Decoupled composition for plugin architectures — later evolved into System.Composition in .NET 5+. 3.5 Dynamic Language Runtime (DLR) Allowed C# to interop with dynamic languages: () == numerator / denominator)
Contract.Requires(denominator != 0); Contract.Ensures(Contract.Result<int>() == numerator / denominator); return numerator / denominator;
Parallel.For(0, 1000, i => Compute(i)); var task = Task.Run(() => LongRunningOperation()); await task; // Not yet native; used ContinueWith in 4.0
var results = source.AsParallel() .Where(x => x.IsValid) .Select(x => x.Transform) .ToList(); Runtime and static checking for pre/post-conditions: