範圍可能不是合適的詞。使用下面的代碼我無法訪問集合元素的對象的屬性。有更好的返回數據類型還是訪問這些屬性的方法?如何訪問其範圍之外的匿名對象的屬性?
protected object Modules()
{
DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/"));
var folders = from x in di.GetDirectories()
where
!(new string[] {
"app_data","bin","obj","scripts","styles","properties"
}).Contains<string>(x.Name.ToLower())
select new
{
Name = x.Name,
Path = x.FullName
};
return folders
}