1. 概述

能够将一个变量带入一个方法中进行改变,改变完成后,再将改变后的值带出方法。

2. 示例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            double salary = 5000;
            Jiangjin(ref salary);
            Console.WriteLine(salary);
            Console.ReadKey();
        }

        public static void Jiangjin(ref double s)
        {
            s += 500;
        }
    }

}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
3. 运行结果

【C#】ref参数_Threading