Skip to content

Instantly share code, notes, and snippets.

@ichiroku11
Last active January 25, 2019 00:01
Show Gist options
  • Save ichiroku11/66745dcbe7cc98ea6d92efd141639e34 to your computer and use it in GitHub Desktop.
Save ichiroku11/66745dcbe7cc98ea6d92efd141639e34 to your computer and use it in GitHub Desktop.
Enumerable.PrependとEnumerable.Append(https://github.com/ichiroku11/Sample に移動)
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