我做这样的事情,并集合中的值不会更改为什么我不能编辑IEnumerable的元素?
[Test]
public void EnumerableTest()
{
var source = GetFoos();
source.First().One = "hello";
Assert.AreEqual(source.First().One, "hello");
//it fails
}
//I actually return this from a repository
public IEnumerable<Foo> GetFoos()
{
yield return new Foo() {One = "1", Two = "2", Three = true};
yield return new Foo() {One = "1", Two = "2", Three = true};
yield return new Foo() {One = "1", Two = "2", Three = true};
}
IsEqualTo()?尝试使用Equals()。 – tgiphil 2010-06-03 09:00:21
@tgiphil对不起,这是我自己的扩展,它有 – Omu 2010-06-03 09:02:13