Overview of New Features in .NET 10

Library Improvements Numeric Ordering for String Comparison In .NET 10, the System.String class adds a CompareAsNumbers method for comparing strings as numbers. This is very useful for sorting strings that contain numbers, such as file names or version numbers. StringComparer numericStringComparer = StringComparer.Create(CultureInfo.CurrentCulture, CompareOptions.NumericOrdering); Console.WriteLine(numericStringComparer.Equals("02", "2")); // Output: True foreach (string os in new[] { "Windows 8", "Windows 10", "Windows 11" }.Order(numericStringComparer)) { Console.WriteLine(os); } // Output: // Windows 8 // Windows 10 // Windows 11 HashSet<string> set = new HashSet<string>(numericStringComparer) { "007" }; Console.WriteLine(set.Contains("7")); // Output: True UTF-8 Support for Hexadecimal String Conversion .NET 10 adds UTF-8 support for hexadecimal string conversion operations in the Convert class. These new methods provide an efficient way to convert between UTF-8 byte sequences and hexadecimal representations without intermediate string allocations: ...

March 10, 2026

What is New in C# 12

Primary constructors One major feature in C# 12 is primary constructors. A primary constructor is declared on the type declaration instead of inside the class body. Its parameters can be used directly in members. Record types public record Address(string FirstName, string LastName); Class types public class Person(string firstName, string lastName) { public override string ToString() { return $"{firstName},{lastName}"; } } public Person(string firstName) : this(firstName, "hello") { } Collection expressions C# 12 adds collection expressions for concise collection initialization. // Create an array: int[] a = [1, 2, 3, 4, 5, 6, 7, 8]; // Create a list: List<string> b = ["one", "two", "three"]; // Create a span Span<char> c = ['a', 'b', 'c', 'd', 'e', 'f', 'h', 'i']; // Create a jagged 2D array: int[][] twoD = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; // Create a jagged 2D array from variables: int[] row0 = [1, 2, 3]; int[] row1 = [4, 5, 6]; int[] row2 = [7, 8, 9]; int[][] twoDFromVariables = [row0, row1, row2]; Range and index usage sequence[0] is the first element. ^n means counting from the end. For any number n, index ^n is equivalent to sequence.Length - n. ...

March 10, 2026