samples/TodoApp/TodoApp.Data/Extensions/CollectionExtensions.cs
/// <summary>
/// Clears the collection and replaces the contents with the provided content.
/// </summary>
/// <typeparam name="T">The type of the collection model.</typeparam>
/// <param name="collection">The collection.</param>
/// <param name="items">The new list of items.</param>
Clears the collection and replaces the contents with the provided content.
Clears the collection and replaces the contents with the provided content .
public static void ReplaceAllItems<T>(this Collection<T> collection, IEnumerable<T> items)
        {
            collection.Clear();
            foreach (var item in items)
            {
                collection.Add(item);
            }
        }
public static void ReplaceAllItems < T > ( this Collection < T > collection , IEnumerable < T > items ) { collection . Clear ( ) ; foreach ( var item in items ) { collection . Add ( item ) ; } }
Clears the collection and replaces the contents with the provided content.
Clears the collection and replaces the contents with the provided content .
Collection<T>
this
items
IEnumerable<T>
The new list of items.
The new list of items .
collection
None
typeparam
The type of the collection model.
The type of the collection model .