“没有重载需要2个参数”,但IntelliSense显示带有2个参数的重载(“No overload takes 2 arguments” but IntelliSense shows overload with 2 arguments)
如果以前有人问过我,我很抱歉,我已经搜索过它,但找不到任何可以解决我困惑的事情。
如果我编写下面的代码,我会得到一个编译器错误
No overload for method 'Contains' takes 2 arguments
,但IntelliSense表明有一个重载需要2个参数( 此处为截图 ):string s = "Hello"; if (s.Contains('h', StringComparer.OrdinalIgnoreCase)) { Console.WriteLine("True!"); }
我传递一个字符作为第一个参数和
StringComparer
实现IEqualityComparer
所以我不明白什么是错的。任何人都可以解释为什么我会收到错误吗
I'm sorry if this has been asked before, I have searched for it but can't find anything that answers my confusion.
If I write the following code, I get a compiler error saying
No overload for method 'Contains' takes 2 arguments
, but IntelliSense suggests that there IS an overload that takes 2 arguments (screenshot here):string s = "Hello"; if (s.Contains('h', StringComparer.OrdinalIgnoreCase)) { Console.WriteLine("True!"); }
I'm passing a char as first argument and
StringComparer
implementsIEqualityComparer
so I don't get what is wrong.Can anyone explain why I get an error?
原文:https://stackoverflow.com/questions/49152427
最满意答案
如果您只是想获取网址,并且没有其他理由坚持使用OCamlnet,那么您可以使用
curl
库,这将解决所有注意事项:let fetch fname url = let fd = open_in fname in let write s = Out_channel.output_string fd s; String.length s in let conn = Curl.init () in Curl.set_writefunction conn (write); Curl.set_failonerror conn true; Curl.set_followlocation conn true; Curl.set_url conn url; Curl.perform conn; Curl.cleanup conn; close_out fd
它将获取curl支持的任何URL,包括
https
If you just want to get the url, and have no other reasons to stick with OCamlnet, then you can just use
curl
library, that will take care of all caveats:let fetch fname url = let fd = open_in fname in let write s = Out_channel.output_string fd s; String.length s in let conn = Curl.init () in Curl.set_writefunction conn (write); Curl.set_failonerror conn true; Curl.set_followlocation conn true; Curl.set_url conn url; Curl.perform conn; Curl.cleanup conn; close_out fd
It will fetch any url supported by curl, including
https
相关问答
更多-
没有“http | https”的网址(URL without “http|https”)[2023-12-07]
协议相对URL 某些浏览器中可能出现的异常安全警告。 另请参阅使用协议相对URL在HTTP和HTTPS之间切换 。 Protocol relative url. You may receive unusual security warnings in some browsers. See also, Wikipedia Protocol-relative URLs for a brief definition. At one time, it was recommended; but going forwa ... -
原来的答案: uri = URI.parse("https://example.com/some/path") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true @data = http.get(uri.request_uri) 正如在评论中指出的那样,这更加优雅: require "open-uri" @data = URI.parse("https://example.com/some/path").read Original ...
-
HTTPS网址是否加密?(Are HTTPS URLs encrypted?)[2022-06-03]
是的,SSL连接在TCP层和HTTP层之间。 客户端和服务器首先建立安全的加密TCP连接(通过SSL / TLS协议),然后客户端将通过该加密的TCP连接发送HTTP请求(GET,POST,DELETE ...)。 Yes, the SSL connection is between the TCP layer and the HTTP layer. The client and server first establish a secure encrypted TCP connection (via th ... -
您无法重定向远离SSL验证错误,因为SSL验证是在重定向发生之前完成的。 没有解决方法。 You cannot redirect away from a SSL verification error because the SSL verification is done before the redirect happens. No workarounds.
-
Ocaml如何获取https网址(Ocaml how get https url)[2021-11-22]
如果您只是想获取网址,并且没有其他理由坚持使用OCamlnet,那么您可以使用curl库,这将解决所有注意事项: let fetch fname url = let fd = open_in fname in let write s = Out_channel.output_string fd s; String.length s in let conn = Curl.init () in Curl.set_writefunction conn (write); Curl.set_fa ... -
不要使用完全限定的URL,请尝试使用相对URI。 而不是将URL指定为.... url: ""+location.hostname+" /member/actions/config-login2.php" 指定为, url: "member/actions/config-login2.php" 在AJAX调用中 如果它不起作用,JSONP是一个很好的替代品 请查看此帖子 Dont use fully qualified URLs, please t ...
-
你需要在你的index.js中设置变量publicServerURL (不能 这是我的: publicServerURL: process.env.SERVER_URL || 'http://localhost:1337/parse', 然后你可以很容易地将它设置在Heroku的环境变量下。 或者将其设置为与serverUrl相同的值 You need to set the variable publicServerURL in your index.js (can't Here's mine: publ ...
-
您需要将RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]的主机更改为SSL证书验证的域名。 听起来您的SSL证书只会验证www.example.com而不是example.com ,因此,如果您发出请求http://example.com您将被重定向到https://example.com ,而您未经过验证证书...因此你得到一个错误。 而是将您的规则更改为: RewriteRule (.*) https://www.example. ...
-
您应该使用RedirectMatch RedirectMatch 301 ^/([^.]+)\.html$ https://example.com/$1 You should use RedirectMatch RedirectMatch 301 ^/([^.]+)\.html$ https://example.com/$1
-
试试这段代码: RewriteEngine On RewriteCond %{HTTPS} on RewriteCond %{THE_REQUEST} !/(area-restrita|page2) [NC] RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=302] RewriteCond %{HTTP_HOST} !^www\.example\.com\$ RewriteRule (.*) http://www.example.com.b ...