Популярное

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

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

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

Топ запросов

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

C# Yield Statements Explained Simply: A Beginner's Guide

Автор: STARTUP HAKK

Загружено: 2023-05-25

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

Описание:

#coding #codingbootcamp #softwaredeveloper

Enter to win free tuition! Enter below!
https://startuphakk.com/start-now/?v=...

GitHub Repo: https://github.com/slthomason/Startup...


C# offers a wide range of tools to make your code shorter, faster and more efficient. Yield statement is one of them, although we tend to forget about it or perhaps don’t know how to use it, it offers great improvement to your code.

Throughout this article, we will understand what C# has to offer with this statement and how we can use it.

What does a Yield Return return ?
Yield return returns the interface IEnumerator or IEnumerable that allows us to iterate over the result using foreach or applying LINQ to the result. The yield statement in C# informs the complier that this block of code is an iterator block.

An iterator block aims to produce a sequence of values ​​of the same type. The type of the returned values ​​is called yield type. When the iterator block returns an IEnumerable or an IEnumerator, the yield type is object. When the iterator block returns an IEnumerable or an IEnumerator, the yield type is T.

Yield in C# allows us to do 2 things :

Custom iteration
If I say write me a method that takes a collection of integers as parameters and returns only values above 5.
Here we got rid of the intermediate list and we don’t have to iterate through both lists to print results so we improved ressrouce usage and we made the code shorter and easier to maintain.

Statefull iteration
If I say write me a method that takes returns running total of a list of integers.
Here the Yield returns the calculated total each time it’s changed and keeps it state for the next calculation.

C# Yield Statements Explained Simply: A Beginner's Guide

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

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

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

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

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

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

array(10) { [0]=> object(stdClass)#4480 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "HRXkeaeImGs" ["related_video_title"]=> string(49) "C# Yield Return: What is it and how does it work?" ["posted_time"]=> string(21) "4 года назад" ["channelName"]=> string(13) "Brian Lagunas" } [1]=> object(stdClass)#4453 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "LiP3s6zjiHU" ["related_video_title"]=> string(59) "Statik Dəyişkən Nədir? Real Örnəklər ilə İzah!" ["posted_time"]=> string(22) "10 дней назад" ["channelName"]=> string(10) "Kod Qutusu" } [2]=> object(stdClass)#4478 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "AAz8q6dOCYk" ["related_video_title"]=> string(71) "Intro to Yield in C# - What it is, how to use it, and when it is useful" ["posted_time"]=> string(21) "3 года назад" ["channelName"]=> string(11) "IAmTimCorey" } [3]=> object(stdClass)#4485 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "P5Lah3YlkpQ" ["related_video_title"]=> string(109) "Полное изучение C++ / Курс в одном видео для начинающих с нуля" ["posted_time"]=> string(25) "2 месяца назад" ["channelName"]=> string(54) "Школа itProger / Программирование" } [4]=> object(stdClass)#4464 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "qTetsXmZLk0" ["related_video_title"]=> string(63) "IAsyncEnumerable, My Favorite C# 8 Feature That No One Is Using" ["posted_time"]=> string(21) "2 года назад" ["channelName"]=> string(18) "Amichai Mantinband" } [5]=> object(stdClass)#4482 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "-6DWwR_R4Xk" ["related_video_title"]=> string(125) "ООП на простых примерах. Объектно-ориентированное программирование" ["posted_time"]=> string(21) "3 года назад" ["channelName"]=> string(7) "Ulbi TV" } [6]=> object(stdClass)#4477 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "dpvRDJjUJf8" ["related_video_title"]=> string(119) "GOLANG ПОЛНЫЙ КУРС ДЛЯ НАЧИНАЮЩИХ | ЧАСТЬ 1 | ОСНОВЫ ПРОГРАММИРОВАНИЯ" ["posted_time"]=> string(23) "1 месяц назад" ["channelName"]=> string(10) "nilchanpub" } [7]=> object(stdClass)#4487 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "A2P3Gn2_gSY" ["related_video_title"]=> string(114) "ВЕСЬ JavaScript в одном собеседовании. 200 вопросов + 70 задач за 2 часа" ["posted_time"]=> string(23) "1 месяц назад" ["channelName"]=> string(40) "Reactify | Frontend Разработка" } [8]=> object(stdClass)#4463 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "wDmPgXhlDIg" ["related_video_title"]=> string(121) "Python — полный курс для начинающих. Этот навык изменит твою жизнь." ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(39) "Александр Ильин про IT" } [9]=> object(stdClass)#4481 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "3UdX6G7a38U" ["related_video_title"]=> string(50) "Intro To Yield In C# - Beginner Examples In Action" ["posted_time"]=> string(27) "7 месяцев назад" ["channelName"]=> string(10) "Dev Leader" } }
C# Yield Return: What is it and how does it work?

C# Yield Return: What is it and how does it work?

Statik Dəyişkən Nədir? Real Örnəklər ilə İzah!

Statik Dəyişkən Nədir? Real Örnəklər ilə İzah!

Intro to Yield in C# - What it is, how to use it, and when it is useful

Intro to Yield in C# - What it is, how to use it, and when it is useful

Полное изучение C++ / Курс в одном видео для начинающих с нуля

Полное изучение C++ / Курс в одном видео для начинающих с нуля

IAsyncEnumerable, My Favorite C# 8 Feature That No One Is Using

IAsyncEnumerable, My Favorite C# 8 Feature That No One Is Using

ООП на простых примерах. Объектно-ориентированное программирование

ООП на простых примерах. Объектно-ориентированное программирование

GOLANG ПОЛНЫЙ КУРС ДЛЯ НАЧИНАЮЩИХ | ЧАСТЬ 1 | ОСНОВЫ ПРОГРАММИРОВАНИЯ

GOLANG ПОЛНЫЙ КУРС ДЛЯ НАЧИНАЮЩИХ | ЧАСТЬ 1 | ОСНОВЫ ПРОГРАММИРОВАНИЯ

ВЕСЬ JavaScript в одном собеседовании. 200 вопросов + 70 задач за 2 часа

ВЕСЬ JavaScript в одном собеседовании. 200 вопросов + 70 задач за 2 часа

Python — полный курс для начинающих. Этот навык изменит твою жизнь.

Python — полный курс для начинающих. Этот навык изменит твою жизнь.

Intro To Yield In C# - Beginner Examples In Action

Intro To Yield In C# - Beginner Examples In Action

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



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



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