Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

New C# 11 Keyword - required - and How To Use It Right

Автор: Zoran on C#

Загружено: 2022-11-22

Просмотров: 3111

Описание:

Become a patron and get access to source code and exclusive live streams:   / new-c-11-keyword-81381466  

The 'required' keyword, introduced in C# 11, is completing the cycle started in C# 9, when init-only setters were introduced. By combining object initializers with required properties, we can redefine the process of instantiating classes.
A required member must be initialized at the time of construction. Failing to do so will cause a compile-time error, because compiler is performing due diligence on every instantiation of an object which declares required members.
Special attention is paid to constructors. Every constructor that sets all required members - fields or properties - must be adorned with the SetsRequiredMembers attribute. That is the signal to the constructor that a use of that constructor is safe, from perspective of the required members. If this attribute is not set, then the constructor would expect all required members to be set using the initializer right after the call to the constructor.
It is important to note that there is no "middle ground". A constructor is either considered to set all required members, or all required members must appear in the initializer, regardless of what the constructor actually does.

Chapters:
00:00 Intro
00:31 Initializing properties before C# 11
03:02 Using the required keyword in C# 11
04:09 Using the SetsRequiredMembers attribute
06:07 Using required properties in nondestructive mutation

Learn more from video courses:
Beginning Object-oriented Programming with C# ► https://codinghelmet.com/go/beginning...
Collections and Generics in C# ► https://codinghelmet.com/go/collectio...
Making Your C# Code More Object-oriented ► https://codinghelmet.com/go/making-yo...

Other courses at Pluralsight ► https://codinghelmet.com/go/pluralsight
Other courses at Udemy ► https://codinghelmet.com/go/udemy

Other videos on this channel you may be interested in watching:
Using GitHub Copilot to Write Complex Code | Step-by-step Tutorial ►    • Using GitHub Copilot to Write Complex Code...  
Coding with GitHub Copilot - Beginner to Master | VS Code Demo ►    • A Comprehensive Guide to GitHub Copilot: F...  
What is Covariance and Contravariance in C# ►    • What is Covariance and Contravariance in C...  
How to Initialize a Clean ASP.NET Core Project with Entity Framework Core and Identity ►    • How to Initialize a Clean ASP.NET Core Pro...  
The Null Conundrum: A Guide to Optional Objects in C# ►    • How to Avoid Null Reference Exceptions: Op...  

New C# 11 Keyword - required - and How To Use It Right

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

array(10) { [0]=> object(stdClass)#5679 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "ZKoSMvmo-ck" ["related_video_title"]=> string(33) "Formally Proving Code Correctness" ["posted_time"]=> string(21) "2 года назад" ["channelName"]=> string(11) "Zoran on C#" } [1]=> object(stdClass)#5652 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "4evWM-HVWmA" ["related_video_title"]=> string(42) "Will All My Classes Look Like Records Now?" ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(11) "Zoran on C#" } [2]=> object(stdClass)#5677 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "gpOQl2q0PTU" ["related_video_title"]=> string(54) "Build Your Own Option Type in C# and Use It Like a Pro" ["posted_time"]=> string(21) "2 года назад" ["channelName"]=> string(11) "Zoran on C#" } [3]=> object(stdClass)#5684 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "VCGXubxKL9I" ["related_video_title"]=> string(69) "How "out" works in C# and why "in" can make or break your performance" ["posted_time"]=> string(21) "3 года назад" ["channelName"]=> string(12) "Nick Chapsas" } [4]=> object(stdClass)#5663 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "NDweaZZZcbc" ["related_video_title"]=> string(70) "C# Nullable reference types – No more null reference exceptions!" ["posted_time"]=> string(21) "4 года назад" ["channelName"]=> string(12) "Filip Ekberg" } [5]=> object(stdClass)#5681 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "aCBohi8BndY" ["related_video_title"]=> string(80) "Правила хуков в React - учим раз и навсегда! #react" ["posted_time"]=> string(22) "11 дней назад" ["channelName"]=> string(33) "Михаил Непомнящий" } [6]=> object(stdClass)#5676 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "CYrlY3ujh6Q" ["related_video_title"]=> string(61) "CURSO C# | Manejo de Clases | Métdos GET y SET en C#" ["posted_time"]=> string(20) "21 час назад" ["channelName"]=> string(13) "El Profe Tech" } [7]=> object(stdClass)#5686 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "F2s71wbx-VY" ["related_video_title"]=> string(78) "LINQ SelectMany Is Slowing Your Application – Here’s How to Fix It" ["posted_time"]=> string(19) "4 дня назад" ["channelName"]=> string(11) "Zoran on C#" } [8]=> object(stdClass)#5662 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "RnHC1XiNWS8" ["related_video_title"]=> string(94) "Венедиктов – страх, Симоньян, компромиссы / вДудь" ["posted_time"]=> string(19) "4 дня назад" ["channelName"]=> string(10) "вДудь" } [9]=> object(stdClass)#5680 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "HAybBV-A1Gg" ["related_video_title"]=> string(47) "Should You Use a Class, Struct or Record in C#?" ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(23) "Bald. Bearded. Builder." } }
Formally Proving Code Correctness

Formally Proving Code Correctness

Will All My Classes Look Like Records Now?

Will All My Classes Look Like Records Now?

Build Your Own Option Type in C# and Use It Like a Pro

Build Your Own Option Type in C# and Use It Like a Pro

How

How "out" works in C# and why "in" can make or break your performance

C# Nullable reference types – No more null reference exceptions!

C# Nullable reference types – No more null reference exceptions!

Правила хуков в React - учим раз и навсегда! #react

Правила хуков в React - учим раз и навсегда! #react

CURSO C#  |  Manejo de Clases | Métdos GET y SET en C#

CURSO C# | Manejo de Clases | Métdos GET y SET en C#

LINQ SelectMany Is Slowing Your Application – Here’s How to Fix It

LINQ SelectMany Is Slowing Your Application – Here’s How to Fix It

Венедиктов – страх, Симоньян, компромиссы / вДудь

Венедиктов – страх, Симоньян, компромиссы / вДудь

Should You Use a Class, Struct or Record in C#?

Should You Use a Class, Struct or Record in C#?

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]