Good Article: http://jonskeet.uk/csharp/parameters.html#ref
I come from the C++ world and logically this confused me about 2 years ago, I stumbled upon this piece of code again, thought Id post it.
UD01 newRow = new UD01(); Db.UD01.Insert(newRow); newRow.Company = Session.CompanyID; newRow.Key1 = "12345"; newRow.ShortChar01 = "abcde"; Db.Validate(); txScope.Complete();
I couldn’t grasp how I can Db.UD01.Insert(newRow); and then assign values after it, Db.Validate() would still accept it just fine. Logically in my mind, I should assign it values, and then call Insert. I certainly never passed it in with the ref keyword, that’s why I was confused. But it didn’t matter. C# by default assumes ref, not in all cases.
I knew about the ref keyword and have been using it, but never assumed .NET by default passed things through as ref.