For Answers, see/post comments

How can i split the sting in C#.Net

I have a string and i want to split the string in two part.f
or example

i have a string like "SNP_A-1998569 2 3 4 5 1 0 4 2 3 1 4 0"
and i want only "SNP_A-1998569".
how can i do it in C#.Net

which function i can use to get the desired string

can u give me the code.

2 comments:

Anonymous said...

String ss = "SNP_A-1998569 2 3 4 5 1 0 4 2 3 1 4 0";

String x = ss.Split(' ')[0];

Anonymous said...

hi,
you can used split function this way
ex your string is

str = "SNP_A-1998569 2 3 4 5 1 0 4 2 3 1 4 0";

string[] strsplit = str.split(' ');
then in first string array you got your value.

strsplit.GetValue(0).ToString()