我发现结果$ request.ContentType是使用char []和String的区别.
$ request = [System.Net.HttpWebRequest] .create($ URL)
Run Code Online (Sandbox Code Playgroud)$request.ContentType = [char[]] "application/x-www-url-formurlened" $request.ContentType = "application/x-www-url-formurlened"
如果我使用char []和string发出了类似的请求,那么到服务器端的实际输出有什么不同?
这太令人困惑......我想它应该是一样的
谢谢
我想我弄明白了这个问题.看一下这个:
PS D:\> $foo = "bar"
PS D:\> $foo
bar
PS D:\> $faz = [string][char[]]"baz"
PS D:\> $faz
b a z
Run Code Online (Sandbox Code Playgroud)
Powershell会将你char[]转换为a string,因为HttpRequest.ContentType它是类型的string,但是当Powershell将数组转换为字符串时,它会$OFS在每个元素之间插入特殊变量的值.about_special_variables的帮助包含有关$OFS(和其他内容)的信息.默认值$OFS是一个解释此行为的空间.
(感谢BartekB在评论中指出$ OFS.)
| 归档时间: |
|
| 查看次数: |
1329 次 |
| 最近记录: |