小编puf*_*ish的帖子

ReadOnlyCollection IEnumerable

string[] _myStrings = { "Hello", "There", "Happy", "Day" };

public IEnumerable<string> MyStrings1
{
    get
    {
        return new System.Collections.ObjectModel.ReadOnlyCollection<string>(_myStrings);
    }
}

public IEnumerable<string> MyStrings2
{
    get
    {
        return from s in _myStrings select s;
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经看到一些关于不使用数组用于公共属性的讨论.我一直在使用" MyStrings2公约".有什么理由我应该使用MyStrings1吗?

.net c# linq

8
推荐指数
1
解决办法
5461
查看次数

默认字符串排序顺序

默认排序顺序是实现细节吗?或者如何选择默认比较器?

这让我想起了忠告。“不要在数据库中存储哈希码”

以下代码是否保证按相同顺序对字符串进行排序?

string[] randomStrings = { "Hello", "There", "World", "The", "Secrete", "To", "Life", };
randomStrings.ToList().Sort();
Run Code Online (Sandbox Code Playgroud)

.net c#

4
推荐指数
1
解决办法
3213
查看次数

标签 统计

.net ×2

c# ×2

linq ×1