且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在多行文本框中逐行获取?

更新时间:2023-12-04 13:23:40

使用 ^ ]方法,即:
Split the TextBox''s Text property using the String.Split[^] method, that is:
string[] sep = new string[] {"\r\n"};
string[] lines = textBox.Text.Split(sep, StringSplitOptions.RemoveEmptyEntries);


您将得到一个由string组成的数组,每个数组对应于另一行.


you get an array of strings, each one corresponding to a different line.


您可以使用 ^ ].

示例:
You can use Regex.Split()[^] for this.

Example:
string[] lines = Regex.Split(txtAddress.Text, "\r\n");


<asp:textbox id="TextBox1" runat="server" textmode="MultiLine" height="100px" width="300px" :asp="#unknown">
        <asp:button id="Button1" runat="server" text="Button" asp="#unknown" />