using System; using System.Collections.Generic; using System.Text; namespace ref_demo { class Program { static void changI(ref int i) { i = 10; } static void changeJ(out int j) { j = 12; } static void Main(string[] args) { int i = 0;//要初始化 int j;//不用初始化 changI(ref i); changeJ(out j); Console.WriteLine(i); Console.WriteLine(j); Console.ReadLine(); } } } 忘了说ref 和 out 都是通过引用来传递参数的