June 2005 Entries
This is an programmatic anlaysis of Value types and Reference types passed by value and reference with newing the object inside the method. Read the conclusions for a clear cut understanding of this apparent confusing funda. //Value types 'pass by' analysis. // 1. Pass by reference, new obj inside the method. string str = "abc"; modifyStr1(ref str); MessageBox.Show(str); // outputs "x" // 2. Pass by reference, no new obj inside the method. str = "abc"; modifyStr2(ref str); MessageBox.Show(str);//...