AdministrationModuleCollection.Count Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the number of elements in the administration module collection.
public:
property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer
Property Value
The number of AdministrationModule objects in the collection.
Examples
The following example demonstrates the Count property. This code example is part of a larger example provided for the AdministrationModuleCollection class.
base.OnActivated(initialActivation);
if (initialActivation)
{
InitializeComponent();
_serviceProxy = (DemoModuleServiceProxy)
Connection.CreateProxy(Module, typeof(DemoModuleServiceProxy));
AdministrationModuleCollection adminmodules =
_serviceProxy.GetAdminModuleCollection();
ArrayList moduleProviders = _serviceProxy.GetAdminProviderList();
string collectiondisplay = null;
collectiondisplay = adminmodules.ToString() + ":\nThere are "
+ adminmodules.Count + " modules in Administration.config\n\n";
// Use the index to get the second AdministrationModule in the collection.
collectiondisplay = collectiondisplay + "Second module: "
+ adminmodules[1].Name + "\n\n";
// Display the name of each AdministrationModule.
foreach (AdministrationModule adminModule in adminmodules)
{
collectiondisplay = collectiondisplay.ToString()
+ adminModule.Name + "\n";
}
string providersdisplay = null;
providersdisplay = "There are " + moduleProviders.Count
+ " modules in Administration.config\n\n";
// Display the name and type of each AdministrationModuleProvider.
foreach (AdministrationModuleProvider
adminProviderModule in moduleProviders)
{
providersdisplay = providersdisplay + adminProviderModule.Name +
" - " + adminProviderModule.Type + "\n";
}
// Display either AdministrationModuleCollection or
// the AdministrationModuleProvider list.
testLabel.Text = collectiondisplay;
//testLabel.Text = providersdisplay;
}
Remarks
You can use the Count property to set the limits of a loop that iterates through a collection of objects. Because the collection is zero-based, be sure to use the value of Count minus 1 as the upper boundary of the loop.