开发者

Is there an alternative to a foreach statement?

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)
{
    // ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜