Results 1 to 3 of 3

Thread: ref and out parametes

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Answers
    14

    ref and out parametes

    what is difference between ref and out parameter?


  2. #2
    Junior Member
    Join Date
    Nov 2007
    Answers
    24

    Re: ref and out parametes

    Hi,

    If you are passing variable as a Reference parameters, only assigned variables can be passed, it won't allow you to pass unassigned variables.
    When you are passing as a out parameters you can pass unassigned variables as a parameters to method, values should be assigned in the method itself.

    For Example
    Reference parameters
    public static void Method(ref int a,ref int b)
    {
    ..........
    }
    public static void Main()
    {
    int a=12,b=2;
    Method(ref a,ref b);
    }

    Out parameters
    public static void Method(out int a,out int b)
    {
    a=10;
    b=90;
    ....
    }
    public static void Main()
    {
    int a,b;
    Method(out a,out b);
    }


  3. #3
    Junior Member
    Join Date
    Jun 2009
    Answers
    14

    Re: ref and out parametes

    thanks shilpa.c


  4.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact