-
Return Array
Hi all,
THis is a very simple question, and I am just not getting something. How do you return an array from a function in C#. Here is my code:
Code:
private string[] readXML()
{
//do something
}
//here is where I call it
String[] ServerAndDB;
//it breaks on this line saying 'indentifier expected'
ServerAndDB[] = readXML();
Any thoughts?
-
Re: Return Array
Quote:
Originally posted by brianh
Hi all,
THis is a very simple question, and I am just not getting something. How do you return an array from a function in C#. Here is my code:
Code:
private string[] readXML()
{
//do something
}
//here is where I call it
String[] ServerAndDB;
//it breaks on this line saying 'indentifier expected'
ServerAndDB = readXML();
Any thoughts?
Get rid of the square brackets on the last line. Your function looks OK to me, its just the line you are calling it from. You don't use the square brackets unless you are accessing one of the elements inside the array.