我有一个List<ValuePair>
对象:listUserRoleValuePair
。我必须在 foreach 循环的列表中添加ixUser
和name
作为我的值对。我怎样才能添加这个?
List<ValuePair> listUserRoleValuePair = new List<ValuePair>();
var ixUserList= _mapper1.FindUserRoleLike(sName);
User result = null;
foreach (var ixUser in ixUserList)
{
result = new UserMapper(connection).FindById(ixUser);
var name = result.SFirstName + " " + result.SLastName;
//listUserRoleValuePair.Add(ixUser);
// listUserRoleValuePair.Add(
}
我的 ValuePair 课程如下
public class ValuePair
{
private string _index;
private string _sName;
public ValuePair(string index, string sName)
{
_index = index;
_sName = sName;
}
public string Index
{
get { return _index; }
set { _index = value; }
}
public string SName
{
get { return _sName; }
set { _sName = value; }
}
}