Last active
January 25, 2019 00:01
-
-
Save ichiroku11/66745dcbe7cc98ea6d92efd141639e34 to your computer and use it in GitHub Desktop.
Enumerable.PrependとEnumerable.Append(https://github.com/ichiroku11/Sample に移動)
This file contains hidden or 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
using System; | |
using System.Linq; | |
namespace ConsoleApp { | |
class Program { | |
static void Main(string[] args) { | |
// シーケンス | |
var source = new[] { 2, 3, 4 }; | |
// Prepend:シーケンスの先頭に値を追加する | |
Console.WriteLine(nameof(Enumerable.Prepend)); | |
foreach (var item in source.Prepend(1)) { | |
Console.WriteLine(item); | |
} | |
// Prepend | |
// 1 | |
// 2 | |
// 3 | |
// 4 | |
// Append:シーケンスの最後に値を追加する | |
Console.WriteLine(nameof(Enumerable.Append)); | |
foreach (var item in source.Append(5)) { | |
Console.WriteLine(item); | |
} | |
// Append | |
// 2 | |
// 3 | |
// 4 | |
// 5 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment