Using String.Split to split string
Author: DevASP Team
Download Source Code : 709_StringSplitter.zip
In this article you will find a simple trick for splitting the string using string.split to split the string on basis of delimiters.
Here is a simple sample that is used to split the string into array of strings basis on the delimiters. To begin with this drop the two controls a label control and the button control on your web form. The code of your web form is as follows:
Now on button click event add the following control:
In above code my delimiter character is hyphen (-) sign. I have added this delimiter to character array and declare the array of string with name str and split the label text using Split(char[] ch). On the web form I have added the two now label controls using Page.Control.Add(Control ctrl).
This property will add new controls on your form. A very simple trick that I am sure will help you a lot in solving your problem.