Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

C# Split String Example in VB.NET | Split String with Special Characters (comma, underscore etc)

Mar 13, 2013
Introduction:

Here I will explain how to split string in
c#, vb.net using asp.net or split string with special characters in  c#vb.net or Split String with Comma, Space in  c#vb.net.
Description:
  
In previous posts I explained
Remove last character from string in C#, jQuery Remove first or last characters from string, SQL Server Query to remove first last characters from string, and many articles relating to Asp.net, c#, vb.net, JQuery. Now I will explain how to split string in c#, vb.net using asp.net.
To split string we need to write the code as shown below

Split String with one character in C#

protected void Page_Load(object sender, EventArgs e)
{
string istr = "Welcome to aspdotnet-suresh.com.";
string []ostr = istr.Split("-".ToCharArray());
foreach (string s in ostr)
{
Response.Write(s+"<br/>");
}
}
Split String with one character in VB.NET



Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim istr As String = "welcome to aspdotnet-suresh.com."
Dim ostr As String() = istr.Split("-".ToCharArray())
For Each s As String In ostr
Response.Write(s & "<br/>")
Next
End Sub
Output of above code


Welcome to aspdotnet
suresh.com.
Split String with multiple characters in C#


protected void Page_Load(object sender, EventArgs e)
{
string istr = "welcome, to, aspdotnet-suresh.com.";
string []ostr = istr.Split(",-.".ToCharArray());
foreach (string s in ostr)
{
Response.Write(s+"<br/>");
}
}
Split String with multiple characters in VB.NET


Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim istr As String = "welcome, to, aspdotnet-suresh.com."
Dim ostr As String() = istr.Split(",-.".ToCharArray())
For Each s As String In ostr
Response.Write(s & "<br/>")
Next
End Sub
Output of above code

welcome
to
aspdotnet
suresh
com

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

4 comments :

Marees said...

Nice Example....

Unknown said...

This code is useful for me a lot

priyanka soni said...

how to seperate numbers and charaters from string

Anonymous said...

Hi Sir Good Morning,

In my project i need to split all types of files and merge the splited file,can you please help me..
Thanks in Advance.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.