在VB.NET我已經習慣了這樣搞創建匿名類型(VB.NET anonymous types include the notion of Key Fields)時:如何在C#匿名類型中聲明「Key」字段?
Dim prod1 = New With {
Key .Name = "paperclips",
Key .Price = 1.29,
.OnHand = 423
}
但是,我一直沒能找到在C#這樣做的任何方式,因爲它出現Key
關鍵字不受支持。
有沒有什麼辦法可以在C#中表示我只想比較匿名類型中的一些字段時尋找平等?
我總是很驚訝C#和VB之間的小差異。我當然不知道你能做到這一點是VB。 – svick