[問題] 陣列大小的問題
剛剛按照msdn建了一段程式碼
http://msdn.microsoft.com/zh-tw/library/ms171731(VS.80).aspx
namespace SerializationDemoControlLib
{
public partial class SerializationDemoControl : UserControl
{
private String[] stringsValue = new String[1];
public SerializationDemoControl()
{
InitializeComponent();
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public String[] Strings
{
get
{
return this.stringsValue;
}
set
{
this.stringsValue = value;
// Populate the contained TextBox with the values
// in the stringsValue array.
StringBuilder sb =
new StringBuilder(this.stringsValue.Length);
for (int i = 0; i < this.stringsValue.Length; i++)
{
sb.Append(this.stringsValue[i]);
sb.Append("\r\n");
}
this.textBox1.Text = sb.ToString();
}
}
}
}
================================================================
我的問題是,一開始宣告 private String[] stringsValue = new String[1];
不就已經指定大小為 1 嗎
為什麼到後來還可以改變呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.120.103.217
推
01/25 18:14, , 1F
01/25 18:14, 1F
→
01/25 18:15, , 2F
01/25 18:15, 2F
→
01/25 20:55, , 3F
01/25 20:55, 3F
討論串 (同標題文章)
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章