Re: for loop

From: William F. Robertson, Jr. (theman_at_fdrsucks.com)
Date: 12/03/04


Date: Fri, 3 Dec 2004 11:02:34 -0600

You could look at merging your arrays.

string [] strcol = new string [0];
for( int x = 0 ; x < ext.Length ; x++ )
{
    MergeArray( strCol, DirSearch( @"C:\temp", ext[x] ), ref strCol );
}

//this method will combine the two arrays into the third paramter passed by
ref.
private static void MergeArray( string [] array1, string [] array2, ref
string [] output )
{
 string [] newArray = new string[array1.Length + array2.Length];

 Array.Copy( array1, newArray, array1.Length );
 Array.Copy( array2, 0, newArray, array1.Length, array2.Length );

 output = newArray;
}

This solution will continue to combine the string array results from your
DirSearch method into one array. When you bind it to your datagrid, it will
show all the items in the array.

bill

"huzz" <huzz@discussions.microsoft.com> wrote in message
news:EC9FBB85-E22C-4015-8D83-0909C3FC5F85@microsoft.com...
> I have a function that returns array, i want to call this function inside
a
> for loop as shown below.. the problem i have i i always get the result for
> the .gif as it is the last entry in ext array. how do i combine the
results
> and maybe use a seperator in between each results? many thanks
>
> string[] ext = new string[3];
> ext[0] = "*.mp3";
> ext[1] = "*.bmn";
> ext[2] = "*.gif";
>
> string[] strCol = new string[3];
> for(int x = 0; x < ext.Length; x++)
> {
> strCol = DirSearch("C:\\TEMP",ext[x]);
> }
> DataGrid1.DataSource = strCol;
> DataGrid1.DataBind();



Relevant Pages

  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... I might handle the array. ... I actually have been wondering if I could use a second string ... look at insertion cost, organization cost, and search cost. ...
    (microsoft.public.vc.mfc)
  • Re: Array Type Mismatch
    ... Dim resultAs String ... I am still somewhat confused as to why nothing is stored in the array. ... Public Function TextBoxGetLine(....arguments... ...
    (microsoft.public.access.formscoding)
  • Re: NumberFormatException:please help me......!!!
    ... Record that has string and array of double as members) and file could ... follows it on a line of the input file, you could use the String as a key to ... contain String representations of doubles. ...
    (comp.lang.java.programmer)