我已经从 CodePlex 下载并检查了 Microsoft 的 MVC 源代码。根据源代码,类定义如下:
namespace System.Web.Mvc
{
public class SelectListItem
{
/// <summary>
/// Gets or sets a value that indicates whether this <see cref="SelectListItem"/> is disabled.
/// </summary>
public bool Disabled { get; set; }
/// <summary>
/// Represents the optgroup HTML element this item is wrapped into.
/// In a select list, multiple groups with the same name are supported.
/// They are compared with reference equality.
/// </summary>
public SelectListGroup Group { get; set; }
public bool Selected { get; set; }
public string Text { get; set; }
public string Value { get; set; }
}
}
但是当我写下面的代码
List<System.Web.Mvc.SelectListItem> statuses = (from s in DataContext.OfferStatuses
select new System.Web.Mvc.SelectListItem
{
Value = s.Id.ToString(),
Text = s.Code,
}).ToList();
在类属性定义中,我看不到“已禁用”属性。此外,当我遍历状态集合时,我仍然看不到该属性。
为什么我看不到一些定义为公共的属性?