string s= bbb.EndInvoke(ar); BeginInvoke(new MyDelegat(PrintThat), new object[] {s}); 

Interested in - ,new object[] {s})
Why s in braces?

    1 answer 1

    In this expression

     new object[] {s} 

    an array of objects is created from one element, which is initialized by the string s . As a result, a reference to this array is passed as the second argument to the call to the BeginInvoke method BeginInvoke

     BeginInvoke( new MyDelegat(PrintThat), new object[] {s} ); 

    This is more clearly seen from the array declarations. For example,

     string s = "Hello"; object[] a = new object[] { s }; object[] a1 = new object[1] { s }; object[] a2 = { s }; 

    Or such an array declaration and output of its elements to the console

     object[] a = new object[] { "Hello", "World" }; Console.WriteLine("{0}, {1}!", a[0], a[1]); 

    In this case, an array with two elements will be created according to the number of initializers.

    For completeness, you can run the following code snippet.

     string s = "Hello"; Console.WriteLine(new object[] { s }[0]); 

    The string "Hello" will be displayed on the console.

    • 2
      in addition: the type of elements in such a record can be omitted, and then it will be output by the compiler, as the most common for the specified elements. - Grundy