gpt4 book ai didi

c# - 到底什么是 String.LegacyMode 属性?

转载 作者:太空狗 更新时间:2023-10-29 23:15:27 26 4
gpt4 key购买 nike

当我反编译时String.IndexOf (String)方法,我看到了;

[__DynamicallyInvokable]
public int IndexOf(string value)
{
return this.IndexOf(value, string.LegacyMode ? StringComparison.Ordinal : StringComparison.CurrentCulture);
}

第二个参数定义中:

  • 如果 string.LegacyModetrue,则评估 StringComparison.Ordinal
  • 如果 string.LegacyModefalse,则评估 StringComparison.CurrentCulture

但是 String.LegacyMode 到底是什么意思呢?

当我反编译这个属性时,我看到了这个:

internal static bool LegacyMode
{
get
{
return CompatibilitySwitches.IsAppEarlierThanSilverlight4;
}
}

我搜索了 String.LegacyModeCompatibilitySwitches.IsAppEarlierThanSilverlight4首先在 Google 上,但我找不到任何有用的信息。

你能教教我吗?

最佳答案

为什么不检查源代码,MSDN :)

Ninja 编辑:我刚刚看到您在问题顶部发布的链接。从其他版本下拉列表中选择 Silverlight,您将看到下面的注释。

String.IndexOf Method

Notes to Callers

Starting in Silverlight 4, the behavior of the String.IndexOf(String) method has changed. In Silverlight 4, it performs a case-sensitive and culture-sensitive comparison using the current culture to find the first occurrence of value. This conforms to the behavior of the String.IndexOf(String) method in the full .NET Framework. In Silverlight 2 and Silverlight 3, String.IndexOf(String) performs an ordinal comparison. If the common language runtime determines that a Silverlight-based application was compiled using either Silverlight 2 or Silverlight 3, it performs an ordinal comparison; otherwise, it performs a culture-sensitive comparison.

关于c# - 到底什么是 String.LegacyMode 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19515004/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com