I want to do a foreach on each child in my app.config but there is no public definition for 'GetEnumerator' in System.ServiceMod开发者_开发问答el.Configuration.CustomBindingCollectionElement I would not ask if this were my own class, but it is a System one. Is there something I can use instead of the foreach to loop through each child in the BindingsSection?
This is what I want to perform the foreach on
BindingsSection bindingsSection = ConfigurationManager.GetSection("system.serviceModel/bindings") as BindingsSection;
BindingCollections
is a List
that has a method called ForEach
, so you can do something like this:
bindingsSection.BindingCollections.ForEach( e => {do something here});
You can use foreach
, but you loop through its BindingCollections
property, like this:
BindingsSection bindingsSection = ConfigurationManager.GetSection("system.serviceModel/bindings") as BindingsSection;
foreach (BindingCollectionElement collection in bindingsSection.BindingCollections)
{
// ...
}
精彩评论