Ref Local Field - CSharp Language Basics

CSharp examples for Language Basics:ref

Description

Ref Local Field

Demo Code

using System;//  www  .  j  a  v a 2s.com
using System.ComponentModel;
class RefLocalField
{
   private int value;
   static void Main()
   {
      var obj = new RefLocalField();
      ref int tmp = ref obj.value;
      tmp = 10;
      Console.WriteLine(obj.value);
      obj = new RefLocalField();
      Console.WriteLine(tmp);
      Console.WriteLine(obj.value);
   }
}

Result


Related Tutorials