In c# I am trying to implement a method which I can use to bind data to any control I pass to it (provided of course the control is derived from a databoundcontrol object)>
Andrew Hare is correct, but in this case, you may not even want to be using the ref
. Objects in C# are already passed by reference*. (As opposed to value types, which are not passed by reference unless you use the ref
keyword.) There are very few cases that I can think of where you'd actually need to pass a reference type in that way. Without the ref
, your original code should work just fine.
**Not really, but it's easier to understand that way if you come from a non-C# background. The reference is actually passed by value. There is an excellent article on the exactly how this all works.*