相关疑难解决方法(0)

没有关键字段的VB.NET匿名类型在比较时与C#匿名类型有何不同?

我正在摸不着头脑,因为我无法理解为什么会发生以下情况:

'//VB.NET
Dim product1 = New With {.Name = "paperclips", .Price = 1.29}
Dim product2 = New With {.Name = "paperclips", .Price = 1.29}

'compare product1 and product2 and you get false returned.

Dim product3 = New With {Key .Name = "paperclips", Key .Price = 1.29}
Dim product4 = New With {Key .Name = "paperclips", Key .Price = 1.29}

'compare product3 and product4 and you get true returned.

'//C#
var product5 = new {Name = "paperclips", Price = 1.29};
var …
Run Code Online (Sandbox Code Playgroud)

c# vb.net anonymous-types

5
推荐指数
1
解决办法
941
查看次数

标签 统计

anonymous-types ×1

c# ×1

vb.net ×1