从字符串c#中分离出Cc电子邮件地址

时间:2013-08-07 08:42:54

标签: c# string split

假设您有来自电子邮件应用程序的一串Cc电子邮件地址,例如

hello@test.com; hello@test.co.uk; hi@test.com;

如何将这些分隔成单独的字符串?

2 个答案:

答案 0 :(得分:3)

emailAddresses.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); 

答案 1 :(得分:2)

你可以使用字符串的分割功能:

string cc = "hello@test.com; hello@test.co.uk; hi@test.com;";

string[] emails = cc.Split(';');
foreach (string email in emails)
{
    Console.WriteLine(email);
}

HTH