我是真的新的C#和我试图解决一些代码使用亚马逊SES发送电子邮件的测试。C#字符串到列表
[TestMethod()]
public void SendEmailTest()
{
SESEmailProvider target = new SESEmailProvider();
string ToEmailAddresses = "[email protected]";
string FromEmailAddress = "[email protected]";
string Subject = "Test";
string EmailBody = "Hello world.";
string expected = string.Empty;
string actual;
actual = target.SendEmail(ToEmailAddresses, FromEmailAddress, Subject, EmailBody);
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
在Visual Studio中的错误信息是:
string SESEmailProvider.SendEmail(
System.Collections.Generic.List<string> ToEmailAddresses,
string FromEmailAddress, string Subject, string EmailBody)
Error:
The best overloaded method match for 'MyServices.SESEmailProvider.SendEmail(
System.Collections.Generic.List<string>, string, string, string)'
has some invalid arguements.
我认为这个问题是,它预计ToEmailAddresses是一个列表,而不是一个字符串,但我在努力寻找一种方法转换/处理这个。
谢谢!
请注意,您可以用逗号分隔多个值来初始化列表,例如..... {“item1”,“item2”,“item3”} – Jason
谢谢 - 这工作完美。等待时间一到,我会尽快接受答案。再次感谢! – Matt