In the following example I want var to still be a ref inside someFunc(). Do i need to attach ref to the argument signature again, or will it still be a ref from the initial pass?
public void foo(ref MyStruct var){
someFunc(var);
}
public void someFunc(MyStruct var){
var;
}
My example has a struct being passed since according to http://www.yoda.arachsys.com/csharp/parameters.html that should mean it passes by value instead of reference as a class does. Am I right about that?
The ref is required.
If you think about it a bit, what if someone called someFunc directly and wanted to pass by ref? You would have to use the ref syntax then right? It doesn’t matter where a function is called from, if you want to pass a struct by reference, you have to use the ref syntax.