且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

包含不正常

更新时间:2021-08-12 22:35:36

引用:

包含未显示的方法intelisense

contains method not shown intelisense



那是因为包含不是静态方法:它是一个实例方法,所以你在实际字符串上调用它:


That's because Contains is not a static method: it's an instance method so you call it on the actual string:

if (business.Cuisine.Contains("chicken"))
   {
   ...



并且没有包含方法,允许您指定不区分大小写。

但是IndexOf方法deos,正如您所发现的那样在互联网上。



但正如我在你用Regexes尝试时向你解释的那样:

如何处理regx.ismatch中的空值 [ ^ ]

您需要自己检查和处理空值!系统不会为你做那件事 - 这是设计上的,而且是完全正确的......



请问,在104个问题之后,你应该对此非常称职现在的东西,不是一遍又一遍地犯同样的错误......这让你看起来就像你在这里学到的东西一样,这只会让你成为帮助吸血鬼。


And there is no Contains method that allows you to specify case insensitivity.
But the IndexOf method deos, as you have found on the internet.

But as I explained to you when you were trying it with Regexes:
How to handle null values in regx.ismatch[^]
You need to check and handle nulls yourself! The system will not do that for you - that is by design, and is absolutely correct...

Please, after 104 questions, you should be pretty competent in this stuff now, not making exactly the same mistake over and over again ... which make you look like you are learning absolutely nothing here, and that would just make you a Help Vampire.


String.IndexOf Method(System)| Microsoft Docs [ ^ ]

String.IndexOf Method (System) | Microsoft Docs[^]
public static bool Contains(this string source, string toCheck, StringComparison comp)
      {
          if (source == null)
              return false;

          return source.IndexOf(toCheck, 0, source.Length, comp) >= 0;
      }