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吗?
默认排序顺序是实现细节吗?或者如何选择默认比较器?
这让我想起了忠告。“不要在数据库中存储哈希码”
以下代码是否保证按相同顺序对字符串进行排序?
string[] randomStrings = { "Hello", "There", "World", "The", "Secrete", "To", "Life", };
randomStrings.ToList().Sort();
Run Code Online (Sandbox Code Playgroud)