Solved

Need to replace this with one line of code

Posted on 2011-09-12
4
205 Views
Last Modified: 2013-12-17
           string[] columns = new string[1];
            columns[0] = "A";
0
Comment
Question by:newbieweb
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now