我创建了以下内容:
public class HttpStatusErrors
{
public HttpStatusErrors()
{
this.Details = new List<HttpStatusErrorDetails>();
}
public string Header { set; get; }
public IList<HttpStatusErrorDetails> Details { set; get; }
}
public class HttpStatusErrorDetails
{
public HttpStatusErrorDetails()
{
this.Errors = new List<string>();
}
public string Error { set; get; }
public IList<string> Errors { set; get; }
}
在我的代码中,我像这样使用它:
var msg = new HttpStatusErrors();
msg.Header = "Validation Error";
foreach (var eve in ex.EntityValidationErrors) {
msg.Details. // Valid so far
msg.Details.Error // Gives the error below:
Ide 认为 msg.Details 是有效的,但是当我尝试编写第二行时,我得到:
Error 3 'System.Collections.Generic.IList<TestDb.Models.Http.HttpStatusErrorDetails>'
does not contain a definition for 'Error' and no extension method 'Error' accepting a first
argument of type 'System.Collections.Generic.IList<TestDb.Models.Http.HttpStatusErrorDetails>'
could be found (are you missing a using directive or an assembly reference?)
C:\K\ST136 Aug 16\WebUx\Controllers\ProblemController.cs 121 33 WebUx
有什么我做错了吗?我认为我设置的方式是在创建第一个类时创建新的列表。