如何在VB.NET中使用Flurl进行GET和POST?我安装了NuGet包并导入了Flurl。
如何将这段C#代码翻译成VB?
var responseString = await "http://www.example.com/recepticle.aspx"
.PostUrlEncodedAsync(new { thing1 = "hello", thing2 = "world" })
.ReceiveString();发布于 2020-05-16 07:12:07
首先,导入相关的命名空间:
Imports Flurl.Http..and,那么这应该是可行的:
Dim responseString = Await "http://www.example.com/recepticle.aspx".
PostUrlEncodedAsync(New With {.thing1 = "hello", .thing2 = "world"}).
ReceiveString()解释:
在VB.NET中,声明匿名对象时,应该使用New With而不是new。此外,属性前面必须有一个点.。
当将语句分成多行时,点不能位于行的开头,因此我们将其添加到前一行的末尾。如果您更喜欢以点开始下一行。您可以使用行连续字符_结束上一行,如下所示:
Dim responseString = Await "http://www.example.com/recepticle.aspx" _
.PostUrlEncodedAsync(New With {.thing1 = "hello", .thing2 = "world"}) _
.ReceiveString()有关更多信息,请参阅:Continuing a statement over multiple lines
https://stackoverflow.com/questions/61829590
复制相似问题