Blog Stats
  • Posts - 42
  • Articles - 0
  • Comments - 98
  • Trackbacks - 34

 

June 2005 Entries

Value types/Reference types - pass by value/reference analysis

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);//...

 

 

Copyright © Vinayak