CollectionFactory 1.2.0

Collection Factory

It's a set of factory methods such as ListOf(1, 2) or ListOf/<int />() to create the basic generic collections. Package was inspired by Kotlin language.

Install-Package CollectionFactory -Version 1.2.0
dotnet add package CollectionFactory --version 1.2.0
<PackageReference Include="CollectionFactory" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CollectionFactory --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Collection Factory

It's a set of factory methods such as ListOf(1, 2) or ListOf<int>() to create the basic generic collections. Package was inspired by Kotlin language.

Reason of use

Why you should use it.? The main reason is much more clean code and providing more "functional programing style in C#".

using static System.Collections.Factory;

...

var dict = new Dictionary<int, string>(){ { 1, "Test" }, { 1, "Test" }, { 1, "Test" } };

var dict = DictionaryOf((1, "Test"), (1, "Test"), (2, "Test"));


var items = new List<int> { 5, 5, 6, 7 };

var items = ListOf(5, 5, 6, 7);

You can use also more shortened version with abbreviations of factory method.

using static System.Collections.AbbreviationFactory;

...

var dict = new Dictionary<int, string>(){ { 1, "Test" }, { 1, "Test" }, { 1, "Test" } };

var dict = DictOf((1, "Test"), (1, "Test"), (2, "Test"));


var items = new Collection<int> { 5, 5, 6, 7 };

var items = CollectOf(5, 5, 6, 7);

Optionaly you can use factory methods to create empty collections.

var dict = new Dictionary<int, string>();

var dict = DictionaryOf<int, string>();
var dict = DictOf<int, string>();

Collection Factory

It's a set of factory methods such as ListOf(1, 2) or ListOf<int>() to create the basic generic collections. Package was inspired by Kotlin language.

Reason of use

Why you should use it.? The main reason is much more clean code and providing more "functional programing style in C#".

using static System.Collections.Factory;

...

var dict = new Dictionary<int, string>(){ { 1, "Test" }, { 1, "Test" }, { 1, "Test" } };

var dict = DictionaryOf((1, "Test"), (1, "Test"), (2, "Test"));


var items = new List<int> { 5, 5, 6, 7 };

var items = ListOf(5, 5, 6, 7);

You can use also more shortened version with abbreviations of factory method.

using static System.Collections.AbbreviationFactory;

...

var dict = new Dictionary<int, string>(){ { 1, "Test" }, { 1, "Test" }, { 1, "Test" } };

var dict = DictOf((1, "Test"), (1, "Test"), (2, "Test"));


var items = new Collection<int> { 5, 5, 6, 7 };

var items = CollectOf(5, 5, 6, 7);

Optionaly you can use factory methods to create empty collections.

var dict = new Dictionary<int, string>();

var dict = DictionaryOf<int, string>();
var dict = DictOf<int, string>();

  • .NETStandard 2.0

    • No dependencies.

Version History

Version Downloads Last updated
1.2.0 125 12/27/2018
1.1.0 122 12/27/2018
1.0.0 105 12/27/2018