当将字符串数组,_lineParts添加到列表时,列表中只显示"System.String []"。需要做什么才能在列表中看到实际的字符串数组值。
while (_aLine != null)
{
//split the line read into parts delimited by commas
_lineParts = _aLine.Split(new char[] { ' ', '\u000A', ',', '.', ';', ':', '-', '_', '/' },
StringSplitOptions.RemoveEmptyEntries);
//keep things going by reading the next line
_aLine = sr.ReadLine();
//words = _lineParts;
if (_lineParts != null)
{
//_words.Add(_lineParts.ToString());
wrd.Add(_lineParts.ToString());
}
}
_lineParts
添加到列表中,而是将_lineParts.ToString()
添加到列表中。对于引用类型,ToString()
的默认行为是输出类型名称,这种情况下是System.String[]
。你是想将数组中的每个单独元素添加到列表中吗?还是想将整个数组作为单个元素添加到列表中? - David