Can we pass ref and out to partial method??

Questions by sambomb3

Showing Answers 1 - 3 of 3 Answers

Deepti

  • Jun 20th, 2014
 

No, Because Out Parameter is used to pass the value out of a method.Out parameters are like return values which must be assigned by the callee. We know a partial method may or may not have an implantation in the case if it does not have a implementation how will it assign value to the out parameters.

Code
  1.  

  2. class tryout

  3. {

  4.     public int mul(int a, out int b)

  5.     {

  6.         b = a * a;

  7.         return b;

  8.     }

  9. }

  10. class Program

  11. {

  12.     static void Main(string[] args)

  13.     {

  14.         tryout to = new tryout();

  15.         int x,y;

  16.  

  17.         x = to.mul(10, out y);

  18.         Console.WriteLine("The output is: "+x);

  19.         Console.ReadLine();

  20.  

  21.  

  22.     }

  23. }

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions