I am trying to pass an array to a subroutine that will populate it. It doesn't like that the array is not initialized before passing it. I don't know how many elements the array will have as that is determined in the subroutine. How can I fix this?
Here is an example
private void x
{
......
string sTestFile = "this is a test";
string[] TestFileWords;
FixConcatString(sTestFile, TestFileWords);
}
private void FixConcatString(string splayfile, string[] sWordArray)
{
char[] charSeparators = new char[] { '-' };
splayfile = splayfile.ToLower();
splayfile = splayfile.Replace(@"\", " ");
sWordArray = splayfile.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
}
It gawks that I am passing TestFileWords to the subroutine without initializing it.
Loading
VulpesPosted Mar 21, 2012, 2:50 PM
The same applies when you use 'ref' rather than 'out'.
Michael CortPosted Mar 21, 2012, 2:49 PM
VulpesPosted Mar 21, 2012, 2:42 PM