ProviderCollection.SetReadOnly 方法


将集合设置为只读。Sets the collection to be read-only.

 void SetReadOnly();
public void SetReadOnly ();
member this.SetReadOnly : unit -> unit
Public Sub SetReadOnly ()


默认ProviderCollection情况下, 此类是可读/写的。The ProviderCollection class is read/write by default. SetReadOnly方法使集合成为只读的。The SetReadOnly method makes the collection read-only. 集合设置为只读后, 某些方法调用 (如RemoveAdd将导致异常。After a collection is set to read-only, some method calls (such as Remove and Add will result in an exception.

请注意, 在创建所有已配置的提供ProviderCollection程序的实例后, 大多数基于提供程序的功能会将其对象设置为只读。Note that most provider-based features will set their ProviderCollection object to read-only after creating instances of all of the configured providers.