Reading the Comma Separated Values from a given String.

vishalneeraj-24503
Posted by vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 442
Suppose,we have below string,here we have to split the string which contains Comma(,) in it.
Below code will demonstrate as:-
C#
string str = "Vishal,Neeraj,Nitin,Amol";
string delimited_str = " ,";
char[] delimiter = delimited_str.ToCharArray();

foreach (string val in str.Split(delimiter))
{
Response.Write(val.ToString() + "<br>");
}

VB.Net
Dim str As String = "Vishal,Neeraj,Nitin,Amol"
Dim delimited_str As String = " ,"
Dim delimiter As Char() = delimited_str.ToCharArray()
Dim val As String = String.Empty

For Each val In str.Split(delimiter)
Response.Write((val.ToString() + "<br/>"))
Next

Output:
Vishal
Neeraj
Nitin
Amol

Comments or Responses

Login to post response