Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Return array

Im trying to make a simple function to remove a string from each element in an array and then return the array (simple ehh)

So, what Ive got is:-
    public class RemoteFolder
    {
        public string RemoveFolderStings(string[] arrFiles, string folderName)
        {
            foreach (var fil in arrFiles)
            {
                fil.ToString().Replace(folderName, "");
            }
            return arrFiles;
        }
    }

Open in new window


However I cant compile as I get the error, on the line 'return arrFiles':-
Cannot convert expression type 'string[]' to return type 'string'

Any ideas how I can fix this?
ASKER CERTIFIED SOLUTION
Avatar of Jeff Darling
Jeff Darling
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tonelm54
tonelm54

ASKER

That was simple :-)

Thank you
Just for clarity.  You specified the function to return a single string, not an array of strings hence the error.  Just do what Jeff says to correct it.