//given a string array 'origStrArr', get a sub string array from 'startIdx', length is 'len' public string[] getSubStrArr(string[] origStrArr, int startIdx, int len) { string[] subStrArr = new string[] { }; if ((origStrArr != null) && (origStrArr.Length > 0) && (len > 0)) { List<string> strList = new List<string>(); int endPos = startIdx + len; if (endPos > origStrArr.Length) { endPos = origStrArr.Length; } for (int i = startIdx; i < endPos; i++) { //refer: http://zhidao.baidu.com/question/296384408.html strList.Add(origStrArr[i]); } subStrArr = new string[len]; strList.CopyTo(subStrArr); } return subStrArr; }
例 6.1. getSubStrArr 的使用范例
string[] fieldExpressions = getSubStrArr(expressions, 1, expressions.Length - 1);