看板 C_Sharp 關於我們 聯絡資訊
剛剛按照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
Elly:啊你在this.stringsValue = value;就改掉了呀 01/25 18:14
Elly:你把他指到別的東西去了,原來的string[1]被你丟到一邊去了 01/25 18:15
freewhat:XD 對喔 我在搞什麼@@ 01/25 20:55