LoginSignup
31
23

More than 5 years have passed since last update.

Listの末尾にListを追加する

Posted at

C#でRubyのArray#+ に相当するやつは何かと思って調べた。

List(T).AddRange メソッド (System.Collections.Generic) だそうな。

addrange.cs
var list = new List<int>(){1, 2, 3};
var l2 = new List<int>(){4, 5};
list.AddRange(l2);
Console.WriteLine("[" + String.Join(", ", from v in list select v) + "]");

実行結果

[1, 2, 3, 4, 5]

関連記事

31
23
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
23