首页 \ 问答 \ “没有重载需要2个参数”,但IntelliSense显示带有2个参数的重载(“No overload takes 2 arguments” but IntelliSense shows overload with 2 arguments)

“没有重载需要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 implements IEqualityComparer so I don't get what is wrong.

Can anyone explain why I get an error?


原文:https://stackoverflow.com/questions/49152427
更新时间:2024-03-13 11:03

最满意答案

如果您只是想获取网址,并且没有其他理由坚持使用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

相关问答

更多
  • 协议相对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 ...
  • 是的,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.
  • 如果您只是想获取网址,并且没有其他理由坚持使用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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。