What's New in C# 12 - Learn Every Single Feature of C# 12 With Example.
In this video we will learn:
Primary Constructor in C# 12:
The primary constructor is a new way of writing the constructors in the C# programming language. We will start learning from
1. What is a Primary Constructor in C# and how to use them in C# applications.
2. How to assign primary constructor parameters to a field or property.
3. How to use multiple constructors with Primary Constructors
4. Difference between Primary Constructors and Records in C# (This is interesting)
5. Passing parameters to parent class constructor while using Primary Constructors
6. Real-Time Use Case of Primary Constructors in C# 12. We will use the primary constructor in asp.net core Web API project to handle the EF Core DbContext Dependency Injections.
Collection Expressions in C# 12: Collection expressions provide the simplest way to define the collections in C#. You will also learn about how to use the spread operator using collection expressions.
Ref Readonly Parameters:
C# introduced "in parameters" to easily pass references that can't be modified. These in parameters work with both variables and values, and you don't need to add any special annotations to use them.
The new "ref readonly parameters" in C# make it clearer when APIs use either ref parameters or in parameters.
Default Lambda Parameters: You can now define default values for parameters on lambda expressions. The syntax and rules are the same as adding default values for arguments to any method or local function.
Alias Any Type: You can use the using alias directive to alias any type, not just named types. That means you can create semantic aliases for tuple types, array types, pointer types, or other unsafe types.
Inline Arrays: Inline arrays are used by the runtime team and other library authors to improve performance in your apps. Inline arrays enable a developer to create an array of fixed size in a struct type. A struct with an inline buffer should provide performance characteristics similar to an unsafe fixed-size buffer.
Experimental Attribute: You can label types, methods, or assemblies with the System.Diagnostics.CodeAnalysis.ExperimentalAttribute to signify an experimental feature. If you try to use a method or type marked with this ExperimentalAttribute, the compiler will give you a warning. All types within an assembly labeled with the Experimental attribute are considered experimental.
Interceptors in C# 12 are added as preview features. An interceptor is a method that can replace a call to a specific method during compilation. This replacement is done declaratively by the interceptor, which specifies the source locations of the calls it intercepts. Interceptors offer a way to alter the behavior of existing code by introducing new code into a compilation, such as in a source generator.
When using an interceptor in a source generator, the goal is to modify existing code rather than add new code. The source generator achieves this by substituting calls to an interceptable method with calls to the interceptor method.
Timestamp:
Introduction to What's New In C# 12 00:00
How to Install C# 12 (System Setup) 01:00
Primary Constructor in C# 12 03:44
C# 12 Collection Expressions in C# 12 19:50
C# 12 Ref Readonly Parameters 24:56
C# 12 Default Lambda Parameters 27:55
C# 12 Alias Any Type 29:16
C# 12 Inline Arrays 33:42
C# 12 Experimental Attribute 35:07
Interceptors in C# 12 37:35
Code Repository: https://github.com/nitish-kaushik/wha...
Смотрите видео What's New in C# 12 - Learn Every Single Feature Added in C# 12 With Example онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь WebGentle 09 Декабрь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,92 раз и оно понравилось 4 людям.