我正在调试 Silverlight 应用程序,并遇到数组索引超出范围的问题。我对 DataTable.Select 语句的语法不够熟悉,并且该应用程序的开发人员接下来的 10 天都在外地。线
searchParamsTable.Select(string.Format("TABLE = {0} AND FIELD = '{1}'", tableNumbers[i], fieldName[i]))[0]["VALUE"] = wildcardedSearchString;
从下面的代码中可以看出,“索引越界”发生在“i”的第二次迭代中,当 i=1 时。我不确定 [0][“VALUE”] 在这种情况下代表什么.如果有人能解释这个字符串中代表什么,我将不胜感激!
if (i < 2 || country != -1)
{
if (!string.IsNullOrEmpty(wildcardedSearchString))
{
searchParamsTable.Select(string.Format("TABLE = {0} AND FIELD = '{1}'", tableNumbers[i], fieldName[i]))[0]["VALUE"] = wildcardedSearchString;
MarkRequiredParametersForSearch(searchParamsTable);
returnList = GetSearchResults(contactType, session, searchParamsTable, returnList,
(int)searchParamsTable.Select(string.Format("TABLE = {0} AND FIELD = '{1}'", tableNumbers[i], fieldName[i]))[0]["FIELDNO"]);
// Filter by authority type if necessary.
if (authorityType != AuthorityType.Unknown)
{
var results = from EntitySearchResult result in returnList
where result.SubType == (int)authorityType
select result;
if (results != null)
{
returnList = results.ToList();
}
}
}
}