ExtensionMethod.NET Home of 829 C#, Visual Basic, F# and Javascript extension methods

Chainable List.Add / typesafe

Allows you to chain .Add method


public static TList Push<TList, TItem>(this TList list, TItem item) where TList : IList<TItem>
    return list;


var listTest = new List<string>().Push("test").Push("test2");
// listTest is now a list with two entries "test" and "test2"

Author: ZBAGI

Submitted on: 12 feb 2019

Language: C#

Type: System.Collections.Generic.IList<T>

Views: 1841