Ref Return from a method - CSharp Language Basics

CSharp examples for Language Basics:ref

Description

Ref Return from a method

Demo Code

using System;/*from ww w.ja  v  a  2  s .co m*/
using System.ComponentModel;
using System.Threading.Tasks;
class RefReturnSimple
{
   static void Main()
   {
      int x = 10;
      ref int y = ref RefReturn(ref x);
      y++;
      Console.WriteLine(x);
   }
   static ref int RefReturn(ref int p)
   {
      return ref p;
   }
}

Result


Related Tutorials