Showing posts with label Pass By Reference. Show all posts
Showing posts with label Pass By Reference. Show all posts

Pass By Reference and Pass By Value

 

Difference Between Pass By Reference And Pass By Value?


Pass By Reference: 

In Pass by reference address of the variable is passed to a function. Whatever changes made to the formal parameter will affect the actual parameters

  1. The same memory location is used for both variables. (Formal and Actual)
  2. It is useful when you are required to return more than 1 value.

Pass By Value:

  1. In this method value of the variable is passed. Changes made to formal will not affect the actual parameters.
  2. Different memory locations will be created for both variables.
  3. Here there will be a temporary variable created in the function stack that does not affect the original variable.

In the case of pass-by value, the change in the sub-function will not cause any change in the main function whereas in pass-by-reference the change in the sub-function will change the value in the main function.

Pass by value sends a COPY of the data stored in the variable you specify, pass by reference sends a direct link to the variable itself. So if you pass a variable by reference and then change the variable inside the block you passed it into, the original variable will be changed. If you simply pass by the value, the original variable will not be able to be changed by the block you passed it into but you will get a copy of whatever it contained at the time of the call.

Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...