StringBuilder错误为“ System.String [] System.String [] System.String []

时间:2018-12-18 09:39:08

标签: c#

当我使用Split(',');方法时,我得到的输出为“ System.String [] System.String [] System.String []

public string GetHrEmail()
{
    StringBuilder sb = new StringBuilder();
    var queryHrExeEmail = from cust in db.EMS_USER_MASTER
                          where cust.ROLE_ID == 17
                          select cust;

    foreach (EMS_USER_MASTER _userMaster in queryHrExeEmail)
    {
        sb.Append(_userMaster.EMAIL.Split(','));
    }
    return sb.ToString();
}

1 个答案:

答案 0 :(得分:1)

使用string.join check this

public string GetHrEmail() 
{
//get users with roleid= 17
var queryHrExeEmail = 
(from cust in db.EMS_USER_MASTER
where cust.ROLE_ID == 17
select cust);

 //selecting emails
var emailList=queryHrExeEmail.Select(e=>e.EMAIL);

//join selected emails with ,
return string.Join(",", emailList);

}