How to convert object to string list?
- by user1381501
I want to get two values by using linq select query and try to convert object to string list.
I am trying to convert list to list.
The code as below.
I got the error when I convert object to string list : return returnvalue = (List)userlist;
public List<string> GetUserList(string username)
{
List<User> UserList = new List<User>();
List<string> returnvalue=new List<string>();
try
{
string returnstring = string.Empty;
DataTable dt = null;
dt = Library.Helper.FindUser(username, 200);
foreach (DataRow dr in dt.Rows)
{
User user = new User();
spuser.id = dr["ID"].ToString();
spuser.name = dr["Name"].ToString();
UserList.Adduser
}
}
catch (Exception ex)
{
}
List<SharePointMentoinUser> userlist = UserList.Select(a => new User { name = (string)a.name, id = (string)a.id }).ToList();
**return returnvalue = (List<string>)userlist;**
}