我在通過這本書列表<T>要求「1」類型參數
http://hookedonlinq.com/LINQBook.ashx
然而,當我嘗試去的過程和實現此代碼
public class Contact
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public DateTime DateOfBirth { get; set; }
public string State { get; set; }
public static List SampleData()
{
return new List {
new Contact { FirstName = "Barney", LastName = "Gottshall", DateOfBirth = new DateTime(1945,10,19), Phone = "885 983 8858", Email = "[email protected]–technology.com", State = "CA" },
new Contact { FirstName = "Armando", LastName = "Valdes", DateOfBirth = new DateTime(1973,12,09), Phone = "848 553 8487", Email = "[email protected]–technology.com", State = "WA" },
new Contact { FirstName = "Adam", LastName = "Gauwain", DateOfBirth = new DateTime(1959,10,03), Phone = "115 999 1154", Email = "[email protected]–technology.com", State = "AK" },
new Contact { FirstName = "Jeffery", LastName = "Deane", DateOfBirth = new DateTime(1950,12,16), Phone = "677 602 6774", Email = "[email protected]–technology.com", State = "CA" },
new Contact { FirstName = "Collin", LastName = "Zeeman", DateOfBirth = new DateTime(1935,02,10), Phone = "603 303 6030", Email = "[email protected]–technology.com", State = "FL" },
new Contact { FirstName = "Stewart", LastName = "Kagel", DateOfBirth = new DateTime(1950,02,20), Phone = "546 607 5462", Email = "[email protected]–technology.com", State = "WA" },
new Contact { FirstName = "Chance", LastName = "Lard", DateOfBirth = new DateTime(1951,10,21), Phone = "278 918 2789", Email = "[email protected]–technology.com", State = "WA" },
new Contact { FirstName = "Blaine", LastName = "Reifsteck", DateOfBirth = new DateTime(1946,05,18), Phone = "715 920 7157", Email = "[email protected]–technology.com", State = "TX" },
new Contact { FirstName = "Mack", LastName = "Kamph", DateOfBirth = new DateTime(1977,09,17), Phone = "364 202 3644", Email = "[email protected]–technology.com", State = "TX" },
new Contact { FirstName = "Ariel", LastName = "Hazelgrove", DateOfBirth = new DateTime(1922,05,23), Phone = "165 737 1656", Email = "[email protected]–technology.com", State = "OR" } };
}
}
我得到的錯誤系統。 Collections.Generic.List要求「1」類型參數我明白列表需要被定義爲如
List<string>
或
List<int>
但無法確定列表應該是什麼。誰能幫忙?
感謝
我認爲你必須指定列表的類型.. – User2012384 2014-10-06 08:23:29
看看我的回答 – User2012384 2014-10-06 08:26:19
補充說明:在看鏈接書的頁面的HTML源文件,你可以看到,它並指定'名單',但'<' and '>'沒有被正確的HTML編碼,所以它不顯示在瀏覽器中。看起來像是一本編程書籍的監督!也可能值得聯繫作者... –
2014-10-06 09:50:39