Re: for loop
From: William F. Robertson, Jr. (theman_at_fdrsucks.com)
Date: 12/03/04
- Next message: bruce barker: "Re: File field control and Web.Config"
- Previous message: Codex Twin: "Re: Rerouting Requests via a Proxy because of .NET "bug""
- In reply to: huzz: "for loop"
- Messages sorted by: [ date ] [ thread ]
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();
- Next message: bruce barker: "Re: File field control and Web.Config"
- Previous message: Codex Twin: "Re: Rerouting Requests via a Proxy because of .NET "bug""
- In reply to: huzz: "for loop"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|