Created
November 26, 2015 09:01
-
-
Save lisardggY/947747cad784d5231830 to your computer and use it in GitHub Desktop.
Find yourself wrapping single objects in arrays or lists to pass to multi-value APIs? Tired of writing new [] {myObject}; all the time? These extension methods will make your collection-wrapping fluent and painless.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static T[] AsSingletonArray<T>(this T single) | |
{ | |
return new[] {single}; | |
} | |
public static List<T> AsSingletonList<T>(this T single) | |
{ | |
return new List<T> {single}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment