嗯......如果你想要的是有人「只是讓這個混賬東西可枚舉」,在這裏不用...
public class ProfilePics : System.Collections.IEnumerable
{
public string status { get; set; }
public string filename { get; set; }
public bool mainpic { get; set; }
public string fullurl { get; set; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
yield break;
}
}
它不枚舉任何東西,但它是可枚舉。
現在,我會盡量搞一些讀心術,不知道,如果你想是這樣的:
public class ProfilePicture
{
public string Filename { get; set; }
}
public class ProfilePics : IEnumerable<ProfilePicture>
{
public List<ProfilePicture> Pictures = new List<ProfilePictures>();
public IEnumerator<ProfilePicture> GetEnumerator()
{
foreach (var pic in Pictures)
yield return pic;
// or simply "return Pictures.GetEnumerator();" but the above should
// hopefully be clearer
}
}
你會想什麼枚舉?我沒有看到任何明顯的數據突出作爲一個很好的候選人。 – aldo 2012-03-20 05:36:59