Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

C# Substring issue with unknown length

$
0
0

I am working with C# code and having issue with substring. My text file as belowenter image description here

Gr= line.Substring(0,5);
SGR = line.Substring(7,3);
subscriber = line.Substring(13,11);
INDV = line.Substring(27,11);
P&C = line.Substring(41,4);
MKR = line.Substring(47,2);Zip_Code= line.Substring(52,10);Zip_City= line.Substring(64,21);
RPTF = line.Substring(87,2);

Getting error on Zip_City string. I am counting it has max of 21 char but it has 19 as in above file so not sure how to adjust it every varying length of string in this column. Length of  each column is fixed as shown above and I am counting spaces between the column as well. I have code written that pick up only  line.StartsWith("60000")

T.I.A


Viewing all articles
Browse latest Browse all 24688

Trending Articles