How to downcast a ref variable within the method
I need to downcast a long to an int in a method where the long is passed as a ref variable: public void Foo(ref long l) { // need to consume l as an int } How can I easily do this? ...
I need to downcast a long to an int in a method where the long is passed as a ref variable: public void Foo(ref long l) { // need to consume l as an int } How can I easily do this? ...
This is not a dupe of Calling a method with ref or out parameters from an anonymous method I am wondering why out parameters are not allowed within anonymous methods. Not allowing ref parameters makes a bit more sense to me, but the out parameters, not as much. what are your thoughts on this ...
When I make an assignment to an out or ref parameter, is the value immediately assigned to the reference provided by the caller, or are the out and ref parameter values assigned to the references when the method returns? If the method throws an exception, are the values returned? For example: int callerOutValue = 1; int callerRefValue...
I have a class that is mostly a wrapper for a big array and some associated housekeeping. I have a function that takes a ref parameter. When I pass an instance of the class into the function, I want the array to get sent. I considered explicit casts. Let's say I have some function that has a byte[] ref parameter. public void Som...
Hello, everyone! I need to find a good and understandable naming-scheme for routines which deal with "value arrays" (I've written something similar to C++'s valarray in Java, with some optimizations for primitive types in mind). I know that the main categorization of routines is made between: functions (they may take parameters and m...