なぜオプション1を使用できないのですか?オプション2は正常に動作しますなぜこのコンパイルエラーが発生していますか?
class Program
{
static void Main()
{
//Option 1
//Error 1 The best overloaded method match for 'ConsoleApplication2.Program.SomeMethod(System.Collections.Generic.List<string>)' has some invalid argument
//Error 2 Argument 1: cannot convert from 'void' to 'System.Collections.Generic.List<string>'
SomeMethod(new List<string>().Add("This give compilation Error"));
//Option 2
List<string> MyMessages = new List<string>();
MyMessages.Add("This compiles fine");
SomeMethod(MyMessages);
}
static void SomeMethod(List<string> Messages)
{
foreach (string Message in Messages)
Console.WriteLine(Message);
}
}
他の返事は私がやっているばかげたことを指しているので正しいですが、これは本当にやりたいことです。ありがとうございました –
時にはその男が起こる... –