How to convert object to string list?

Posted by user1381501 on Stack Overflow See other posts from Stack Overflow or by user1381501
Published on 2014-08-25T04:10:42Z Indexed on 2014/08/25 4:20 UTC
Read the original article Hit count: 114

Filed under:
|

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;**


    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ