You will get some more speed out of using for instead of foreach, which will
get you away from multiple "Iterator lookups".
---orig
Date: Sat, 17 Jan 2004 18:31:01 -0500
From: Shawn Wildermuth <[EMAIL PROTECTED]>
Subject: Re: AW: [ADVANCED-DOTNET] Fastest way to add contents of ArrayList
to a DataTable
Assuming the DataSet is hurting performance, you'll want to add this =
code=20
ArrayList userList =3D theDirectory.getUsers();
// Starts bulk loading=20
// Defers indexing and constraint checking // till EndLoadData();
tblUsers.Users.BeginLoadData();
if (userList !=3D null)
{
foreach (UserDirectoryObject user in userList)
{
DataRow drUser =3D tblUsers.NewRow();
drUser["lastName"] =3D user.lastName;
drUser["firstName"] =3D user.firstName;
/* etc */
tblUsers.Rows.Add(drUser);
}
}
// Ends the bulk loading
===================================
This list is hosted by DevelopMentor� http://www.develop.com
Some .NET courses you may be interested in:
NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com