Navigation
Search
|
Microsoft moves forward with C# 13, offering overload resolution
Wednesday July 10, 2024. 09:08 PM , from InfoWorld
Microsoft, in its latest informational update on the planned C# 13 language release, is emphasizing capabilities such as overload resolution, with developers able to supply multiple params overloads when authoring a method, and partial properties, similar to partial methods.
The company published its latest blog on C# 13 on July 9. C# 13 is likely to be finalized in November, along with the latest update to the planned.NET 9 software development platform. In detailing overload resolution, Microsoft said that when authoring a method, developers can supply multiple params overloads. This can reduce allocations, which can improve performance. Multiple overloads can both boost performance and add convenience. Library authors are advised to give all overloads the same semantics so callers do not need to be concerned about which overload is used. Partial properties, meanwhile, are described as being like partial method counterparts. It will be easier for source generator designers to create APIs with a natural feel. Also in C# 13, the release refines the rules for determining the natural type to consider candidates by scope and to prune candidates with no chance of succeeding. Updating these rules means fewer compiler errors when working with method groups. The release, with allows ref struct, also adds a new way to specify capabilities for generic type parameters. By default, parameters cannot be ref struct. C# 13 lets developers specify the type can be a ref struct, and applies appropriate rules. When other generic constraints limit the set of types that can be used as a type parameter, the new specification expands the allowed types. This removes rather than adds a restriction. In another improvement in C# 13, async methods can declare ref local variables or local variables of a ref struct type. These variables cannot be preserved across an await boundary or a yield return boundary. In this fashion, C# 13 allows the unsafe context in iterator methods. C# 13 also extends params, a feature previously cited by Microsoft. With C# 13, params will be extended to work with any type that can be constructed via a collection expression. This adds flexibility whether developers are writing a method or calling it. Beginning with C# 13, params parameters can be of any type that is supported for collection expressions. Elsewhere in C# 13, the language makes it easy to use a new System.Threading.Lock type featured in.NET 9. This type is for mutual exclusion, which can be more efficient than locking on an arbitrary System.Object instance. C# 13 also introduces a new escape sequence for the ESCAPE or ESC character. The new sequence is especially convenient when interacting with terminals with the VT100/ANSI escape codes to System.Console.
https://www.infoworld.com/article/2515587/microsoft-moves-forward-with-c-13-offering-overload-resolu...
Related News |
25 sources
Current Date
Dec, Sun 22 - 14:56 CET
|