0
string s = "0082002100071254 INR 008200    XYZAPQRDEFGHIJK            0.00 Cr    03100";
string[] arraytempline2 = s.split(','); 
MessageBox.Show("Length of Line : " + arraytempline2.Length);

After spliting its giving the length as 1
But i want to seperate the above string
And According to me its length should be 6
But i am not getting what is wrong with my code

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Arjun_Sarankulu
1

you are setting the split symbol as ','. since you have no commas in your string, that's why it's not splitting anything.

you have to set the split symbol as a ' ', (space)

0

The Split method cannot find a ',' (comma) character to split your string, so it returns the whole string. That is why the arraytempline2 string array returns 1 as Length. arraytempline2[0] = s
I think it's better to use the LastIndexOf method, looking for a space and then chop your string with the SubString method.

0

Thank Momerath for giving valuable time
I got what you are saying is Right
Substring is one of the solution to get three string from one string

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.