This question already has an answer here:
这个问题在这里已有答案:
- F#, assignment operator vs set operator 2 answers
F#,赋值运算符vs set运算符2的答案
As I understand it, it should be possible to set the content of a response message like so:
据我了解,应该可以设置响应消息的内容,如下所示:
let responseMessage = new HttpResponseMessage(HttpStatusCode.OK)
responseMessage.Content = new StringContent("test")
However, when doing so I get the following error:
但是,这样做时我收到以下错误:
Parser Error: This expression was expected to have type HttpContent but here has type StringContent
解析器错误:此表达式应具有类型HttpContent,但此处具有类型StringContent
I'm doing this in a tests project in order to stub a response. It's targeting .NET 4.5 and FSharp Core 4.3.1.0
我在测试项目中这样做是为了存根响应。它的目标是.NET 4.5和FSharp Core 4.3.1.0
1 个解决方案
#1
As ildjarn said, =
is equality comparison, <-
is assignment.
正如ildjarn所说,=是平等比较,< - 是任务。
let responseMessage = new HttpResponseMessage(HttpStatusCode.OK)
responseMessage.Content <- new StringContent("test")
#1
As ildjarn said, =
is equality comparison, <-
is assignment.
正如ildjarn所说,=是平等比较,< - 是任务。
let responseMessage = new HttpResponseMessage(HttpStatusCode.OK)
responseMessage.Content <- new StringContent("test")