How to create a reference to System.Array while holding strings in C #

I have an interesting question about C # code. Basically, I need to call a method

BCI2000AutomationLib.IBCI2000Remote.StartupModules(ref System.Array) 

Using Visual Studio 2010, the following code compiles and works fine:

 // Startup modules string[] modules = new string[3]; modules[0] = "SignalGenerator --local"; modules[1] = "DummySignalProcessing --local"; modules[2] = "DummyApplication --local"; ok_conn = bci.StartupModules(ref modules); 

Now porting this to a game engine (such as Unity 3D) requires stricter C # code since it uses the Mono C # compiler. Therefore, for the same code, I get the following compilation error:

The best overloaded method match for 'BCI2000AutomationLib.IBCI2000Remote.StartupModules (ref System.Array)' has some invalid arguments Argument 1: cannot convert from 'ref string []' to 'ref System.Array'

Can you give advice on how to rewrite this code block to a more strict encoding to eliminate the declared error?

+4
source share
2 answers

Change the type of the variable to System.Array

 // Startup modules Array modules = new string[3] { "SignalGenerator --local", "DummySignalProcessing --local", "DummyApplication --local" }; ok_conn = bci.StartupModules(ref modules); 

Your StartupModules method takes an Array argument as an argument; it can set a variable to any other array. Not necessarily an Array string, it can be int []. This is why you cannot call with a variable printed as an Array string.

+4
source

A String Array program that takes a string from a user:

 class Program { static void Main(string[] args) { int i,j; string[] str = new string[10]; Console.WriteLine("Enter the Name of your friends"); for (i = 0; i < 10; i++) { str[i] = Convert.ToString(Console.ReadLine()); Console.WriteLine("Array["+i+"]="+str[i]); } Console.ReadLine(); } } 
-1
source

All Articles