Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Feature Forums
  3. - Uncategorised posts -
  4. Pass by reference, Pass by value

Pass by reference, Pass by value

Scheduled Pinned Locked Moved - Uncategorised posts -
question
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yBrian
    wrote on last edited by
    #1

    Why understanding pass by value and past by reference are important in order to learn a programming language?

    N L P R 4 Replies Last reply
    0
    • Y yBrian

      Why understanding pass by value and past by reference are important in order to learn a programming language?

      N Offline
      N Offline
      Nitin Singh India
      wrote on last edited by
      #2

      When you are passing something to another function, it can get modified within that. The importance comes into picture if you want to know what happens after the function returns. If you do not care about the post-return stage, then you can pass by value/reference, it doesn't affects your application logic in anyway. However, if you are concerned with the after value, you need to pass by reference. Apart, given the framework implementation, an object is a heavyweight construct. So if we keep on passing such a huge object by creating a copy, it will hog up memory causing hung application and GC trigger. Hence the framework will auto (most i believe) will pass an object by reference and cause any changes to that be available outside the function as well. You can also pass a value type (structure) as reference, in which case it will be boxed into a reference type and then passed. C# allows you to explicitly specify "ref" and "out" decorators on parameters. If applied either, the changes are visible after the function return, else by default it gets passed as value.

      1 Reply Last reply
      0
      • Y yBrian

        Why understanding pass by value and past by reference are important in order to learn a programming language?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Take a look at .NET Book Zero[^], where Charles Petzold expalins it in very good detail.

        Veni, vidi, abiit domum

        1 Reply Last reply
        0
        • Y yBrian

          Why understanding pass by value and past by reference are important in order to learn a programming language?

          P Offline
          P Offline
          Paul Guralivu
          wrote on last edited by
          #4

          A good post about the importance by ref or by value can be found here: http://www.yoda.arachsys.com/java/passing.html[^] Also there are some examples on the page about it. Paul Joseph.

          Y 1 Reply Last reply
          0
          • P Paul Guralivu

            A good post about the importance by ref or by value can be found here: http://www.yoda.arachsys.com/java/passing.html[^] Also there are some examples on the page about it. Paul Joseph.

            Y Offline
            Y Offline
            yBrian
            wrote on last edited by
            #5

            Well, it seems more clear by now, thank you :)

            1 Reply Last reply
            0
            • Y yBrian

              Why understanding pass by value and past by reference are important in order to learn a programming language?

              R Offline
              R Offline
              Raushank03
              wrote on last edited by
              #6

              Get Your Solution on http://techgurulab.com/course/asp-net-tutorial/

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups