C# Split 文字 (String) + List
WebForm.aspx |
using System; using System.Collections.Generic; protected void Page_Load(object sender, EventArgs e) { String input = "1,2,2,123,21312,412412,21312,23123,321312"; List<String> output = split_string(input); foreach (string part in output) { Response.Write(part + "<br>"); } } private List<String> split_string(string input) { string[] parts = input.Split(','); List<String> AllItem = new List<string>(); foreach (string part in parts) { AllItem.Add(part); } return AllItem; } |