簡體   English   中英

string.IndexOf(string) 的 StringComparison 方法是什么?

[英]What is the StringComparison method of string.IndexOf(string)?

我知道string.IndexOf("some string")正在執行區分大小寫和區分文化的比較。

MSDN 頁面

[...] 此方法使用當前區域性執行單詞(區分大小寫和區域性)搜索。 搜索從該實例的第一個字符 position 開始,一直持續到最后一個字符 position。 [...]

但是,這是否意味着它等同於使用string.IndexOf("some string", StringComparison.CurrentCulture)
我想知道StringComparison的哪個精確成員正在使用或等效使用。

是的。

這是源代碼: https://source.dot.net/#System.Private.CoreLib/String.Searching.cs,cf9e6bfe83442551,references

public int IndexOf(string value)
{
    return IndexOf(value, StringComparison.CurrentCulture);
}

是的,.NET 框架(和核心)源可用,所以這里是相關代碼: https://referencesource.microsoft.com/#mscorlib/system/string.cs,2307

 public int IndexOf(String value) { return IndexOf(value, StringComparison.CurrentCulture); }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM