Results 1 to 2 of 2

Thread: Return Array

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    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?

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Return Array

    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.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width