C# Invoke() delegate with string array as an argument (winforms)
Assuming sUsernames
is a string[]
then yes, you need to call it with
Invoke(_dLoadUserSelect, new object[] { sUsernames });
.Net arrays are covariant, so this assignment is valid:
string[] sUsernames = new[] { "a", "b", "c" };
object[] objs = sUsernames;
and when calling a method with params arguments, the array is passed directly instead of being passed as the first element in an argument array. You need to manually create the argument array for Invoke
to get the behaviour you expect.