本文介绍了将字符串数组(string [])添加到List< string> C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当将string [],_ lineParts添加到列表中时,我在列表中看到的只是"System.String []" 要查看列表中的实际string []值,需要做些什么.
When the string[], _lineParts is added to the List, all I see in the List is "System.String[]" What needs to be done to see the actually string[] values in the list.
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());
}
}
推荐答案
使用 List.AddRange 而不是List.Add
这篇关于将字符串数组(string [])添加到List< string> C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!