0

I have some code that binds a datagrid to the instances in a custom web config section. It works fine, I can edit, add and delete entries to the grid and then enumerate the rows of the grid and save the result to the custom config section.

BindingSource Source = new BindingSource();
Source.DataSource = EmailCustomSection.Instances;
grdUDL.DataSource = Source;

Now I am in a service enviroment: no grid, no form. I have a test harness that runs the dll defining the service. I want to iterate though the EmailCustomSection.Instances. I can see that the count is 3 as it should be, but every attempt I make to get the [i] instance fails. I'm looking for a way forward.

4

1 に答える 1

1

試す

foreach(var item in EmailCustomSection.Instances)
{
   // do stuff with item
}
于 2013-04-24T08:58:30.277 に答える