ReadOnlyCollectionBaseT

ReadOnlyCollectionBase<T> class

Represents a read-only collection of objects.

public abstract class ReadOnlyCollectionBase<T> : IList<T>
Parameter Description
T Type of collection items.

Properties

Name Description
Count { get; } Gets the number of objects contained in the object.
Item { get; set; } Returns the element at the specified index.

Methods

Name Description
Add(T) This is the stub implementation of ICollection’s Add method, that only throws NotSupportedException
GetEnumerator() Returns an enumerator for this collection.
ToList() Converts the collection object to a list of VbaModule objects.

Examples

Shows how to iterate over VBA modules.

var project = new Project(DataDir + "VbaProject.mpp");
var vbaProject = project.VbaProject;

Console.WriteLine("Total Modules Count: " + vbaProject.Modules.Count);
foreach (var module in vbaProject.Modules)
{
    Console.WriteLine("Module Name: " + module.Name);
    Console.WriteLine("Source Code: " + module.SourceCode);
    Console.WriteLine();
}

// the collection can be converted into a plain list
List<VbaModule> modules = vbaProject.Modules.ToList();
foreach (var unused in modules)
{
    // work with modules
}

See Also