Splitting a string in C#

Posted by Prince | 6:56:00 PM | | 0 comments »

Split a string using c#: 
                                           The String.Split() method used to split one or more string from a line in C Sharp. To split a string we need a separator to set a string length for split. In the following example I'm using the '#'  symbol to separate the strings.

Code:

//Input string = "split#a#string#" 

String[] split; 
split = String.Split('#'); 
str1 = split[0]; //split 
str2 = split[1]; //a 
str3 = split[2]; //string

0 comments

Related Posts Plugin for WordPress, Blogger...