Splitting multiple lines and storing them into array. I found this code snippet useful in my daily office work in order to do so we need to take the input in my case I use multiple line text box. This tutorial is for beginners. In order to do so I made the languages and terms well-defined so let's start with the ready-to-copy code,
sting[] str = str.Split(new [] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
Example of doing so,
my CS page
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace gridcolor {
public partial class WebForm1: System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
string str = textbox1.text;
sting[] str = str.Split(new [] {
"\r\n"
}, StringSplitOptions.RemoveEmptyEntries);
}
}
Here is my aspx page (code),
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="textBox1" runat="server" Height="492px" TextMode="MultiLine"
Width="994px"></asp:TextBox>
</form>
</body>
</html>
That's all hope you like it sharing is caring share with your coding buddies.