I clearly doesn't understand ref and the scope of a parameter good enough. Can someone tell me why this code works? How can you send dt into a function (I mean it will become a parameter and the scope would be as a local variable right?). So why is dt populated(filled) after fill() has been called?
So my first thought was I'm only sending a reference to dt with fill(), but then I doesn't understand the ref keyword. I thought that's what we had that for.. Do you only have to use ref when the parameter is value by type?
var dt = new DataTable();
using (var cmd = new MySqlCommand(cmdText, connection))
using (var adapter = new MySqlDataAdapter())
{
adapter.SelectCommand = cmd;
adapter.Fill(dt); // <---why is ref not needed here?
}
return dt;