{"id":2982,"date":"2019-12-03T14:26:56","date_gmt":"2019-12-03T13:26:56","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=2982"},"modified":"2022-07-25T08:33:24","modified_gmt":"2022-07-25T07:33:24","slug":"c-enumerable-from-single-or-no-arguments","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-enumerable-from-single-or-no-arguments\/","title":{"rendered":"C# Enumerable from single or no arguments"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public static IEnumerable&lt;T> Select&lt;T>(params T[] args) => args;\npublic static List&lt;T> List&lt;T>(params T[] args) => args.ToList();\n\n\/\/ return empty enumerable\nreturn Select&lt;string>(); \/\/ or Enumerable.Empty&lt;string>();\n\/\/ return single value\nreturn Select(\"A\");\n\/\/ return two values\nreturn Select(\"A\", \"B\"); \/\/ For int: Select(1, 2, 3); or doubles Select(1.0, 2.1, 3.2); \n\/\/ For a list\nreturn List(\"A\", \"B\");<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6,4,1],"tags":[],"class_list":["post-2982","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2982","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=2982"}],"version-history":[{"count":4,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2982\/revisions"}],"predecessor-version":[{"id":3791,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2982\/revisions\/3791"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=2982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=2982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=2982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}