ServiceCollection.MakeReadOnly Method

Definition

Makes this collection read-only.

C#
public void MakeReadOnly();

Remarks

After the collection is marked as read-only, any further attempt to modify it throws an InvalidOperationException.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided), 2.1 (package-provided)