0
// Traditional approach,
// fluent interface
BsonArray a2 = new BsonArray().Add(1).Add(2);

// Values argument
int[] values = new int[] { 1, 2 };
BsonArray a3 = new BsonArray(values); //It doesn't work in VB.NET

// Collection initializer syntax
BsonArray a4 = new BsonArray { 1, 2 }; //This doesn't work in VB.NET

特に、 MongoDB VB.NET ドライバーの「内」ボックスを見つけたいと考えています。

次のステートメントを 1 行にまとめるにはどうすればよいですか?

Dim b As New BsonDocument
Dim box As New BsonDocument
Dim d = New BsonArray({{1, 2}, {3, 5}})
box.Add("$box", d)
'box.Add("$box", d)
b.Add("$within", box)
query.Add("$within", box)
4

1 に答える 1

2

2 番目と 3 番目のものは機能しないと言うのはなぜですか? BsonArray コンストラクターには を受け取るオーバーロードがあるIEnumerable(Of Integer)ように見えるため、両方とも機能するはずです (構文が間違っていることを除いて、つまり、正しい構文は次のようになります。

' values argument
Dim values() As Integer = {1, 2}
Dim a3 As BsonArray = New BsonArray(values)

' collection initializer syntax
Dim a4 As BsonArray = New BsonArray(New Integer(){1, 2})
于 2012-08-24T12:05:10.610 に答える