C#: The Heap and the Stack

Sdílet
Vložit
  • čas přidán 4. 03. 2018
  • When programming in C#, it is very important to understand the concept of the heap and the stack. Value types such as integers are stored on the stack. Object types are stored on the heap, with pointers to them stored on the stack. This video explains the heap and the stack with an example and a diagram and demonstrates the dangers that await you if you do not understand this concept.

Komentáře • 49

  • @yawnyawning
    @yawnyawning Před 2 lety +5

    so far the easiest explanation of stack and heap ive seen

  • @yasu3d
    @yasu3d Před 5 měsíci +2

    I've been programming with c# for 2-ish years. I had a solid understanding of certain types being passed by reference instead of value, but never learned what the Heap or Stack *actually* were. This video finally made it click in my head. I'm glad I wasn't missing out on much and just learned some new names for stuff I already kinda knew :]

  • @kipchickensout
    @kipchickensout Před 2 lety +14

    For anyone watching: You can pass value types by reference, by simply prefixing the type in the parameters with a "ref" keyword. Also look up the "out" keyword

  • @unrealdevop
    @unrealdevop Před 4 lety +10

    This is amazing, great job man. This taught me something very valuable that I was completely unaware of before. Not sure why this wasn't properly explained in the books I read.

  • @DylanWRose
    @DylanWRose Před 3 lety +3

    Preparing for the MTA Software Development Fundamentals exam to meet entry requirements for the WGU Data Analytics degree program. This is something that pops up on the test and has always confused me. The way you've explained it is extremely clear.
    Thank you.

  • @gregorio87
    @gregorio87 Před 11 měsíci

    The best explanation I've seen... I remember being a bit confused about this behavior when first learning JavaScript and this nails it in a very clear way. Great job

  • @prasadmadushan
    @prasadmadushan Před 2 lety +1

    Clear explanation with visual Diagram. love it.

  • @TG47GRG
    @TG47GRG Před 3 lety +3

    this is awesome. You made the concept sound very simple and easy to understand. Thank You!

  • @dineshkarn3275
    @dineshkarn3275 Před 3 lety +1

    Very best explanation with practical example. Thanks a lot . Waiting for your next video

  • @yess.6558
    @yess.6558 Před 7 měsíci

    Great video! Thank you!

  • @persiansayed
    @persiansayed Před rokem

    Great demonstration and explanation. Thanks 👍

  • @PatilSandip321
    @PatilSandip321 Před rokem +1

    Nice one

  • @prakashroyal6386
    @prakashroyal6386 Před rokem

    Clear explanation. Thank you for the video!!

  • @moherna3323
    @moherna3323 Před 3 lety

    You're such a great educator

  • @developersfield9018
    @developersfield9018 Před 6 lety +2

    nice and easy to understand explanation...

  • @Tanveer048
    @Tanveer048 Před 2 lety

    Thanks for the Sharing of your knowledge

  • @gregorynovikov1450
    @gregorynovikov1450 Před 2 lety

    This was interesting, Thank-You

  • @lylewarren4391
    @lylewarren4391 Před 10 dny

    king shit, you are a legend.

  • @aliabusaleh4039
    @aliabusaleh4039 Před 3 lety

    thanks man great job

  • @mohamedshaban5170
    @mohamedshaban5170 Před rokem

    Thank you!!

  • @blackbarry45
    @blackbarry45 Před 4 lety +1

    thanks you so much

  • @user-ee5lx8rz3j
    @user-ee5lx8rz3j Před 9 měsíci

    excellent

  • @AnasJayyusi
    @AnasJayyusi Před rokem

    thank you that was amazing explain

  • @mohokhachai
    @mohokhachai Před 11 měsíci

    Finally some one

  • @RageGames_
    @RageGames_ Před 9 měsíci

    Nice

  • @hhcdghjjgsdrt235
    @hhcdghjjgsdrt235 Před 2 lety

    best example

  • @muammar88
    @muammar88 Před 2 lety +1

    Super! Subscribed! ps. would you kindly group your videos by programming language into seperate PlayLists for convinence? Thanks a million for the great contents!

  • @burreifort
    @burreifort Před 2 lety +6

    4:10 No, you didn't change the value of score2

    • @macoson
      @macoson Před rokem

      Yes, this got me to laugh as well :D

  • @at3o
    @at3o Před 2 lety

    💯

  • @shamikaredkar837
    @shamikaredkar837 Před 3 lety +8

    why did i understand this better than what my uni prof taught me? and why am I paying thousands of dollars to the uni only to learn stuff off youtube?

  • @Tanveer048
    @Tanveer048 Před 2 lety

    This super 👌

  • @mujmoh7471
    @mujmoh7471 Před 7 měsíci

    أسطورة

  • @mohokhachai
    @mohokhachai Před 11 měsíci

    This is it

  • @gabrielyea
    @gabrielyea Před 5 lety

    In c# by default everything passes by value, classes pass their reference as a value. That is my understanding, or I am wrong?

  • @wwg681
    @wwg681 Před 3 lety +1

    Can we use struct all the time?

    • @Luizzzzzzzzzzzzzzzzzzzzzzzzzz
      @Luizzzzzzzzzzzzzzzzzzzzzzzzzz Před 3 lety

      Hey have you found the answer to your question?

    • @wwg681
      @wwg681 Před 3 lety

      @@Luizzzzzzzzzzzzzzzzzzzzzzzzzz Nope :(

    • @alissonreinaldosilva1119
      @alissonreinaldosilva1119 Před 3 lety

      @@wwg681 it's not like Struct is an alternative or replacement for Classes, they have different purposes. Depending on how simple your program is, then yeah you can use only struct, nothing will enforce you to use classes (apart from Program class e.g in a console), but depending on your needs it will just make your task harder for no good reason.

  • @Atezian
    @Atezian Před 2 lety

    Is this useful to someones that doesnt know what the stack and the heap are?

  • @ozanbarsakdogdu8360
    @ozanbarsakdogdu8360 Před 3 lety

    in the end of the video you say "int s". Was it "int score"

  • @BlackSaintNiks
    @BlackSaintNiks Před rokem

    Great Learning Video!

  • @metteby
    @metteby Před 5 lety +1

    Good explanation. Please lower keyboard noise

  • @cicher
    @cicher Před 3 lety +6

    Good explanation, but it is not really about "Heap and Stack", the title should be *"Value and Reference types"*

  • @Mr.Epsilion
    @Mr.Epsilion Před 2 lety

    Spassibo = true;

  • @BerikAssylbekov
    @BerikAssylbekov Před 2 lety

    It's wrong. Reference type parameters are passed by value. You can test yourself by setting r = null; The pointer on "r" is removed, but "report" is still has pointer.

  • @WiseWeeabo
    @WiseWeeabo Před 4 lety

    would be useful if you could actually see the text you're writing, how did you mess it up so badly?