Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用户列表,在那个对象上我有一个属性电子邮件。有没有办法在 c# 中使用 lambda 以“email1;email2;email3”的格式返回每个用户电子邮件的单个字符串,最后没有任何分号。谢谢你的帮助。
是的。假设您的User对象列表称为users:
User
users
string emailList = string.Join(";", users.Select(u => u.Email));
from user in listOfUsers select string.Join(";", user.Emails);
感谢yamen发现错误
select string.Join(";", user.Emails.ToArray());