單純簡單的筆記技巧
舉個例子 將 ", 56 , , 65 , 68 , 71 , 75, 78 , 87 ,"中的數值用 List<int> 來收集
設計程式介面:
private void button_test1_Click(object sender, EventArgs e)
{
char[] Test_List1_char = textBox_List1.Text.ToCharArray();
string Test_tmp_string = "";
List<int> Test_collect_ListInt = new List<int>();
for (int i = 0; i< Test_List1_char.Length;i++)
{
if ( int.TryParse(Test_List1_char[i].ToString(),out int int1_tmp))
{
Test_tmp_string = Test_tmp_string + Test_List1_char[i];
}
else
{
if (int.TryParse(Test_tmp_string, out int int2_tmp))
{
Test_collect_ListInt.Add(int2_tmp);
Test_tmp_string = "";
}
}
}
if (int.TryParse(Test_tmp_string, out int int3_tmp))
{
Test_collect_ListInt.Add(int3_tmp);
Test_tmp_string = "";
}
for (int i = 0; i < Test_collect_ListInt.Count; i++)
textBox_Read.Text = textBox_Read.Text + Test_collect_ListInt[i] + "\t";
}
測試結果: