I’ve been wondering if/how the NETMF differs from C# when it comes to passing parameters. As you may know there are two basic methods of passing parameters to a function: by reference or by value.
As I spend most of my times these days coding in C++ I had to look up the proper syntax and a found a good write up here: http://msdn.microsoft.com/en-us/library/0f66670z(VS.71).aspx . A few quick tests similar to what is shown below confirms that the C# NETMF parameter passing works just like .NET on any other platform.
For me it was good to know that when I was passing around an ArrayList, NETMF was not making a new copy of the list to pass about. So if your nor sure what passing by reference or by value is all about take a look at the web-page above for a good explanation.
namespace Reference_Testing
{
public class Program
{
public static void Main()
{
ArrayList value = new ArrayList();
value.Add(0);
Debug.Print("Value before: " + value[0].ToString());
stuff(value);
Debug.Print("Value after: " + value[0].ToString());
Thread.Sleep(100000);
}
public static void stuff(ArrayList value)
{
value[0] = 200;
Debug.Print("Value in sub: " + value[0].ToString());
}
}
}
Output:
Value before: 0
Value in sub: 200
Value after: 200