I have a Dictionary<string, Delegate> commands with my delegate taking two strings and a string[] as params.
I'm entering a command in a Console Application:
:adduser username [email protected] Firstname Middlename Lastname
where everything is converted to an array of strings (size 6). I then do
list[3] = string.Join(" ", input, 3, 3);
list.RemoveRange(4, list.Count - 4);
to convert Firstname, Middlename, and Lastname into a single string, so that my array looks like this:
input[0]: :adduser
input[1]: :username
input[2]: :[email protected]
input[3]: :Firstname Middlename Lastname
I then try to call commands[input[0]].Method.Invoke(this, list.Skip(1).ToArray<object>());, but it results in an ArgumentException with the message
Object of type 'System.String' cannot be converted to type 'System.String[]'.
I'm a bit lost, as I don't really know what's wrong. I'd appreaciate any help!