【发布时间】:2019-08-25 22:40:08
【问题描述】:
我有一个字符串数组,其中包含我想提取的用户名并将其添加到列表中。例如,我有这个字符串 =>“UserName: JohnSmith”,我想提取JohnSmith。以下是我试图开始工作的代码:
var documentSource = content.Replace("\n" , "").Trim();
string[] contents = documentSource.Split(',');
List<Model> modelList = new List<Model>();
Model model = new Model();
foreach (var item in contents)
{
//this is where I'd like to locate the username or usernames
if(item.Any())
{
model.userName = //username only;
modelList.Add(model);
}
}
return modelList;
【问题讨论】:
标签: asp.net arrays string list