C# Yield - Creating Iterators for beginners

Поділитися
Вставка
  • Опубліковано 8 лип 2024
  • 🔥 Is your code getting stuck iterating? Why not fetch data while it is iterating, avoiding freezes entirely? Well, with YIELD, you can do so!
    🚀 C# Progress Academy - Become a job-ready C# and Angular web developer to land your dream developer role: bit.ly/45vbPUg
    We'll make sure to turn you into a true developer in no time!
    Timestamps:
    00:00 Introduction
    00:16 What do we need? And why do we want Yield?
    01:36 Want to improve your C# Skills?
    02:05 Let´s see a problem and build a solution using YIELD Return
    05:38 Thanks for watching!
    C# yield - creating iterators for beginners
    So, what is C#?
    C# (pronounced "See Sharp") is a modern, object-oriented, and type-safe programming language. C# enables developers to build many types of secure and robust applications that run in .NET. C# has its roots in the C family of languages and will be immediately familiar to C, C++, Java, and JavaScript programmers. This tour provides an overview of the major components of the language in C# 8 and earlier. If you want to explore the language through interactive examples, try the introduction to C# tutorials.
    C# is an object-oriented, component-oriented programming language. C# provides language constructs to directly support these concepts, making C# a natural language in which to create and use software components. Since its origin, C# has added features to support new workloads and emerging software design practices. At its core, C# is an object-oriented language. You define types and their behavior.
    And what is the Yield keyword?
    You use the yield statement in an iterator to provide the next value from a sequence when iterating the sequence. The yield statement has the two following forms:
    yield return: to provide the next value in iteration.
    yield break: to explicitly signal the end of iteration.
    The return type of iterators is IEnumerable (in non-generic cases, use IEnumerable as the return type of an iterator). You can also use IAsyncEnumerable as the return type of an iterator. That makes an iterator async. Use the await foreach statement to iterate over iterator's result.
    To learn more, make sure to watch the video, and we promise you that you'll become a better developer by the end of the video! Have fun!
    And thank you LAKEY INSPIRED for these amazing songs that we use in all our videos! @LAKEYINSPIRED
    #csharp #coding #tutorial #learn #microsoft #net #yield #optimization
    TAGS
    c#,.net,c-sharp,csharp,programming,visual studio,c sharp,learn c#,c# programming,c# tutorial,c# for beginners,learn c# programming,c# course,tutorial,coding,c# multithreading,async,thread,multithreading,threading,c# one thread,c# async,core,code,task,async tutorial,asynchronous,shorts,dotnet,yield,ienumerable,yield return vs return c#,yield return,yield statement,yield return statement,iterator pattern c#,c# yield return,yield break,break,return,optimization
    TutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
    This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
    Stay tuned and subscribe to tutorialsEU: goo.gl/rBFh3x
    C#: / @tutorialseuc
    Facebook: / tutorialseu-1093802040...
    LinkedIn: / tutorialseu
    Discord: / discord

КОМЕНТАРІ • 12

  • @tutorialsEUC
    @tutorialsEUC  10 місяців тому +1

    🚀 C# Progress Academy - Become a job-ready C# and Angular web developer to land your dream developer role: bit.ly/45vbPUg

  • @kopilkaiser8991
    @kopilkaiser8991 Рік тому +2

    Definitely a must watch video for every programmer willingful to understand "yield" statement in C#. I myself, have been able to understand thanks to you🎉❤

  • @thomasschroter3802
    @thomasschroter3802 7 місяців тому +2

    Nothing wrong with the content. However, this example shows well how much imperative programming interrupts the actual flow of the program and the developer is constantly forced to use control structures. A declarative approach would clearly have an advantage here.

  • @benderios
    @benderios 25 днів тому

    The best explanation

  • @phattruong7086
    @phattruong7086 4 місяці тому

    It's really really good, I can understand the "yield" in C# thanks for your video! Nice job!

  • @zane4218
    @zane4218 Місяць тому

    Is a yield return function setting up an isolated separate thread? That's what it feels like, but I'm having a little bit of trouble holding the logic in my head (which honestly is the case for a lot of multithreading, this would actually be simpler than normal for that.)

  • @kopilkaiser8991
    @kopilkaiser8991 Рік тому

    ⭐️⭐️⭐️⭐️⭐️

  • @Golden_games
    @Golden_games Рік тому

    but if the max value is large will it not take longer and possibly throw an error

    • @hemanichius3941
      @hemanichius3941 Рік тому

      You mean too large for an int

    • @Golden_games
      @Golden_games Рік тому

      @@hemanichius3941 no I mean if you input a higher value like when he used 1billon will it not still take much time to complete

    • @MrOudoum
      @MrOudoum Рік тому +5

      @@Golden_games Of course it does. Sadly he did not show the console then you would see why yield is very good in this situation. It will print the messages as soon as it iterates through each item because yield provides the next value in the iteration.
      Before the change to yield the methode had to finish (IEnumerable) and after that it will iterate through the foreach loop.

  • @sparkviral5844
    @sparkviral5844 Рік тому

    Create a app pdfscanned to text file