class Program{ static void Main(string[] args) { TestRef t = new TestRef(); t.Something = "Foo"; DoSomething(t); Console.WriteLine(t.Something); } static public void DoSomething(TestRef t) { t.Something = "Bar"; }}public class TestRef{ public string Something { get; set; }}
为什么在传递对象时使用‘ref’关键字?
米脂