8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C#のメモ帳 動的に配列の要素数を増やす

Last updated at Posted at 2017-09-15
動的に配列の要素数を増やすぞ!
string[] 顧客 = new string[0];   //空の配列を作る。

 for(int i= 0; i < 9; i++)
{
	Array.Resize(ref 顧客, i + 1);  //配列のリサイズ。既存値はそのまま。リサイズ直後の値はNull(のようだ)。
	顧客[i] = i;
	Console.WriteLine(顧客[i]);
}

Console.WriteLine("要素数: "+ 顧客.length);
8
9
2

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
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?