/// <summary>
/// 获取导出题号范围
/// </summary>
/// <param name="strRangeText">导出题号范围表达式,如:0,3,5-9,20</param>
/// <returns>List<int>导出题号范围</returns>
private bool getImportNumber(string strRangeText,out List<int> lineList)
{
lineList = new List<int>();
if (strRangeText == null)
{
lineList.Clear();
return false;
}
string[] strArr = strRangeText.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
if (strArr == null)
{
lineList.Clear();
return false;
}
for (int i = 0; i < strArr.Length; i++)
{
string str = strArr[i];
if (!str.Trim().Contains('-'))
{
try
{
int lineNumber = Convert.ToInt32(str.Trim());
if (lineNumber > -1)
{
lineList.Add(lineNumber);
}
}
catch
{
lineList.Clear();
return false;
}
}
else
{
string[] strArr2 = str.Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
if (strArr2.Length > 1)
{
try
{
int intFromPage = Convert.ToInt32(strArr2[0]);
int intToPage = Convert.ToInt32(strArr2[strArr2.Length - 1]);
for (int page = intFromPage; page <= intToPage; page++)
{
lineList.Add(page);
}
}
catch
{
lineList.Clear();
return false;
}
}
else
{
lineList.Clear();
return false;
}
}
}
if (lineList.Count > 0)
{
return true;
}
else
{
return false;
}
}
标签:return,int,lineList,strArr2,导出,获取,false,题号 From: https://www.cnblogs.com/jnmcok/p/18393181