加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

是否有理由为什么System DLL在Silverlight和其他C#库中是不同的

发布时间:2020-12-14 02:26:28 所属栏目:Windows 来源:网络整理
导读:我问的原因是因为我写了一个扩展方法在Silverlight中使用只是为了找出该功能神奇地开始为银光工作. 例 string sentence = "I am a sentence that has some words";sentence.Contains("N"); //would return false,silverlight truesentence.Contains("n"); //
我问的原因是因为我写了一个扩展方法在Silverlight中使用只是为了找出该功能神奇地开始为银光工作.

string sentence = "I am a sentence that has some words";
sentence.Contains("N"); //would return false,silverlight true
sentence.Contains("n"); //would return true,silverlight true

为什么Silverlight框架中有一个特殊的System dll,它将比较作为不区分大小写的?

我已经遇到了大量的方法,它们有点令人讨厌,它们要么行为不同,要么一般都缺失.

解决方法

The reason I am asking is because I wrote an extension method to use in Silverlight only to find out that feature magically started working for silver light.

从2.0开始(2.0,3.0,3.5,4.0,SL 3/4 WP 7.0/7.1),所有版本的.NET都有一个公共bool string.Contains(string)方法.

有趣的是,SL版本仅从SL 3/4中列出 – 您是否可以从2.0解决方案更新?那就可以解释它.

否则,定义的方法总是优先于扩展方法,因此永远不应该调用扩展方法(我们可以排除.NET 1.1,因为C#1.2编译器不包含扩展方法).

对于.NET 2.0 MSDN文档,请将其作为:

This method performs a word (case-sensitive and culture-sensitive) search using the current culture. The search begins at the first character position of this string and continues through the last character position.

所有其他版本(包括Silverlight)列为:

This method performs an ordinal (case-sensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.

如果你没有看到(请高音检查),这可能是一个框架错误…但我谨慎地期待一个更简单的解释.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读