开发者

how to substring from a string using c#

The following is a line of huge .txt file and i am reading it line by line. I need the value of second column. In this line, I need to extract 'C9006'.

Mr ABC|C9006|The white field, ON|493-493-4939|493-493-4939|YR|Inactive

No开发者_开发知识库te : The delimiter char is pipe sign '|'. The length of second column is not consistent.

Help please.


String value = "A|B|C";
String secondColumn = value.split("|")[1];


You can use the Split method of String.


string result = input.Split('|')[1];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜