Simple question of syntax

  • Thread starter Thread starter David P. Donahue
  • Start date Start date
D

David P. Donahue

How do I create an array of something in-line? That is, I'm calling a
function which takes an array of strings as an argument. Knowing how
many elements are in the array and what they are, how would I create
that array within the function call itself? (Something I did often in
VB, but just can't seem to find the correct syntax in C#.)


Regards,
David P. Donahue
(e-mail address removed)
 
Function(new string [2] { "Like ", "this" });
or
Function(new string [] { "Like ", "this" });

The element size specifier is actually optional, as the compiler already
knows it will be 2.
 
Back
Top