Method AsTransientReadOnly
AsTransientReadOnly()
Returns a fast read-only view into the underlying list that is only guaranteed to be valid until the values associated with the Key in Dictionary are modified.
Declaration
public ReadOnlyList<TValue> AsTransientReadOnly()
Returns
Type | Description |
---|---|
ReadOnlyList<TValue> |
Remarks
References to transient lists should only be held for as long as a series of multiple consecutive read-only operations need to be performed on them. Once the values associated with the Key are modified, the transient list's behavior is undefined and it may contain stale values.
It is not beneficial to use a transient list for a single read operation, but when multiple read operations need to be done consecutively (including enumerating over multiple values), slight performance gains may be seen from performing them on the transient read-only list instead of directly on the ListDictionary<TKey, TValue>.ValueList or ListDictionary<TKey, TValue>.ReadOnlyValueList, since the transient list does not check if it needs to re-synchronize with the dictionary.