• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Need to replace this with one line of code

           string[] columns = new string[1];
            columns[0] = "A";
0
newbieweb
Asked:
newbieweb
  • 2
  • 2
2 Solutions
 
wdosanjosCommented:
string[] columns = {"A"};
0
 
newbiewebAuthor Commented:
Fine, but when I try and use {"A"} in a function parameter that expects string[] column, I get the following error:

"Invalid expression term '{"

Why?
0
 
wdosanjosCommented:
string[] columns = {"A"} is a shortcut to string[] columns = new string[]{"A"}.  This type of shortcut can only be used during variable declaration.  So, when you call a function with an array parameter you should use the following syntax:

myfunction( new string[] {"A"} );

0
 
newbiewebAuthor Commented:
Thanks!
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now