Solved

Need to replace this with one line of code

Posted on 2011-09-12
4
210 Views
Last Modified: 2013-12-17
           string[] columns = new string[1];
            columns[0] = "A";
0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 500 total points
ID: 36523472
string[] columns = {"A"};
0
 

Author Comment

by:newbieweb
ID: 36523575
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
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 36523690
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
 

Author Closing Comment

by:newbieweb
ID: 36524152
Thanks!
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

731 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question