How much does Linq.Take take?

17 Apr 2009 in dotnet | libs-and-frameworks |

I wasn’t 100% certain how much the “Take” would take from a list with less elements than the number you want to take. It probably says in the docs, but let me assure you that this test succeeds:

[Test] public void TakeTakesAsMuchAsThereIs() { string[] stuff = {"hi"}; var l = stuff.Take(3).ToList(); Assert.That(l, Has.Count(1)); }


comments powered by Disqus