我是真的新的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