Results 1 to 5 of 5

Thread: Arguments passed by value and reference

  1. #1
    Join Date
    Dec 2010
    Posts
    48

    Arguments passed by value and reference

    I am an student pursuing a course in IT graduation from a reputed institution I am weary weak in programming , and I have my exams ahead after a few days back so I have posted my question in your forum considering this forum to be a very helpful forum as not only in technical issues but also in the development of programs as well, I was reading about the types of arguments being passed as I do not know when and what type of arguments can be passed in the methods.

  2. #2
    Join Date
    May 2009
    Posts
    511

    Re: Arguments passed by value and reference

    In Visual Basic, you can pass an argument to a function either by value or by reference. This is called as the passing mechanism, and it conclude whether the function can change the programming constituent originally having the argument in the invoking code. The function declaration determines the passing process for each argument list by passing the or ByRef (Visual Basic) keyword.

  3. #3
    Join Date
    May 2009
    Posts
    543

    Re: Arguments passed by value and reference

    While giving an argument to a procedure, be cautious of numerous diverse distinctions that communicate with each other:
    • If the underlying programming constituent is changeable or non changeable
    • If the argument itself is changeable or non changeable
    • If the argument is being passed by value or it may also be given a reference as an argument
    • if the data type in the argument list is of value type or is of type reference

  4. #4
    Join Date
    May 2009
    Posts
    637

    Re: Arguments passed by value and reference

    Code:
    using System;
    class passingargs
    {
        static void SqIt(int m)
        
        {
            m *= m;
            Console.WriteLine("The value that is stored in the  method: {0}", m);
        }
        public static void Main()
        {
            int passInt = 5;
            Console.WriteLine("The result before invoking the method: {0}",
               passInt);
            SquareIt(passInt);   
            Console.WriteLine("The result after invoking the method: {0}",
               passInt);
        }
    }
    As in the code you can see in the code the difference when the arguments is passed as a value or reference , you will clearly get the difference when you execute this code , any change made in the actual parameter he value remains intact , but when the argument is passed as reference any change made in the actual parameters reflects in the result as well.

  5. #5
    Join Date
    Apr 2009
    Posts
    488

    Re: Arguments passed by value and reference

    In C# too , arguments can also be given as value or the reference. Passing arguments by reference permits member functions that include not only the methods but also its properties and indexers and the operators to work on them to alter the value of the arguments and have that alteration persist. You will have to explicitly mention the ref or the out keyword to pass an argument by reference. I think you will be able to score decent marks if you even write this much

Similar Threads

  1. Web pages go static when passed through IPS
    By Sera-phina in forum Networking & Security
    Replies: 4
    Last Post: 09-05-2011, 07:51 PM
  2. Volume Control passed to the system by VLC
    By Pales in forum Windows Software
    Replies: 5
    Last Post: 22-11-2010, 10:36 AM
  3. How binary data is passed to HTTP
    By Gannon in forum Software Development
    Replies: 4
    Last Post: 29-01-2010, 04:37 PM
  4. Finally , Passed Ccna With 987 !
    By samyei in forum Education Career and Job Discussions
    Replies: 9
    Last Post: 30-12-2009, 10:17 PM
  5. Can't get passed windows error recovery screen
    By radmanmm in forum Vista Help
    Replies: 2
    Last Post: 24-11-2008, 12:03 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,593,355.10288 seconds with 17 queries