I just read this article by MVP Jon Skeet on Parameter passing in C#. Definitely good reading. It helps to understand exactly how reference and value types work when passing them through methods. Here is a good example of how this helped me:
- Instantiate an instance of Class1 as obj1.
- Instantiate Class2 as obj2.
- Pass obj1 in obj2.Foo(obj1)
- The obj2 also has an instance var for Class1 called myobj1.
- In obj2.Foo(Class1 yourobj1), assign myobj1 = yourobj1.
My question has been if myobj1 is a clone of the value of obj1, or if it’s a real reference to the same value. Indeed both references point to the same space, so I need to be careful about how the instance is handled as I pass it around an application. In VB the word SET would have made this all obvious. The article also made it very clear how passing a reference type with a ref qualifier worked – something that can be very confusing.
See Jon’s other articles and his blog for other good info.
Many wish they had good grasp on technology. I'm all over technology but have few people who want solutions. Demand<Supply? Gotta fix that.
@pickcoder I didn't know you were using @Twilio, bud. I'm sure you know I'm all over that. Lemme know if I can help!
@ElkieHolland D3 (http://t.co/cPp1Dt6c) is very cool but not related to D3 (http://t.co/I5ymHD2s) :^D #multivalue
I thought http://t.co/MvapCjWz was a great find for #multivalue until I realized the bot postings were decade old forum scrapes. #fail
Leave a reply
You must be logged in to post a comment.