Original Post
I found this a little strange.. Maybe I'm having a brain fart here but in Managing Memory section, the author states:
"When you pass in a reference type, we are actually passing a copy of the reference to the data."
He then states, in regards to the 'ref' keyword:
"We should not use this keyword on reference types because it will actually slow things down..."
Then, in Program.cs for the PerformanceChecker, he has this static method signature:
static void PrintPerformance(string label, [color="#ff0000"]ref Stopwatch sw) { ... }
At first I was thinking Stopwatch was a struct, but it is a class. So am I missing something here, or did he just say one thing and do another? There is no reason I see to pass as a reference, as it does not redefine the memory pointer for that reference. It only access the member variables of that object.
"When you pass in a reference type, we are actually passing a copy of the reference to the data."
He then states, in regards to the 'ref' keyword:
"We should not use this keyword on reference types because it will actually slow things down..."
Then, in Program.cs for the PerformanceChecker, he has this static method signature:
static void PrintPerformance(string label, [color="#ff0000"]ref Stopwatch sw) { ... }
At first I was thinking Stopwatch was a struct, but it is a class. So am I missing something here, or did he just say one thing and do another? There is no reason I see to pass as a reference, as it does not redefine the memory pointer for that reference. It only access the member variables of that object.