split string using C#

Splitting string with delimiter


string s = TextBox1.Text;
string[] s1 = s.Split(new char[] { " " });
Console.WriteLine(s1[0]);
Console.WriteLine(s1[1]);

Splitting string with comma ,

string s = TextBox1.Text;
string[] s1 = s.Split(new char[] { "," });
Console.WriteLine(s1[0]);
Console.WriteLine(s1[1]);

Splitting string with &

string s = TextBox1.Text;
string[] s1 = s.Split(new char[] { "&" });
Console.WriteLine(s1[0]);
Console.WriteLine(s1[1]);

Splitting string with string

string s = TextBox1.Text;
string[] s1 = s.Split(new string[] { "and" },StringSplitOptions.None);
Console.WriteLine(s1[0]);
Console.WriteLine(s1[1]);

Hope, you guys found any help with this code. If my code help you in any way,please feel free to revert back with your views


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: