I have a string which is 28000 lines long and is laid out like below:
List<string> sQuerys = new List<string>();
string FullFileQuery = " EXEC spDataCache_INS_XSCDV1P @Company = 'UKC ', @Country = 'AE ', @Trade_Lane = 'ARABIAN GULF/MIDDLE EAST ', @Trade_Region = 'INDIA/PAKISTAN/MIDDLE EAST '
EXEC spDataCache_INS_XSCDV1P @Company = 'UKC ', @Country = 'AL ', @Trade_Lane = 'MEDITERRANEAN ', @Trade_Region = 'EUROPE/MEDITERRANEAN '
EXEC spDataCache_INS_XSCDV1P @Company = 'UKC ', @Country = 'AO ', @Trade_Lane = 'WEST AFRICA ', @Trade_Region = 'AFRICA '
EXEC spDataCache_INS_XSCDV1P @Company = 'UKC ', @Country = 'AR ', @Trade_Lane = 'EAST COAST SOUTH AMERICA ', @Trade_Region = 'LATIN AMERICA '
EXEC spDataCache_INS_XSCDV1P @Company = 'UKC ', @Country = 'AU ', @Trade_Lane = 'AUSTRALIA/NEW ZEALAND ', @Trade_Region = 'FAR EAST AND OCEANIA '"
I want to split the string every 15000th line and add to my list of string sQuerys
.
So the 28000 lines will be split into 15000 lines and 13000 lines and added to the list. I am unsure on the quickest way to achieve this.
EDIT:
The code I have tried doing but I am stuck is below:
if (FullFileQuery.Split('
').Length > 15000)
{
//28000
int numLines = FullFileQuery.Split('
').Length;
//LOOP TWICE.
for (int i = 0; i < ((numLines / 15000) + 1); i++)
{
//NEED TO ADD TO sQuerys in here.
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…