TryGetNonEnumeratedCount? I used to do that by hand! 0 ▲ Siderite's Blog 72 days ago · Tech · hide · Fediverse post Interfaces are cool. They abstract behavior that can be implemented in a lot of different ways. One of the most used interfaces, abstracting the enumerable software pattern so successfully that we have internalized it before we ever knew what a software pattern was, is IEnumerable. It's just a series of things that you can get (enumerate) one after the other until you reach an end. However, there are a lot of situations where knowing the total number of enumerable items helps, like when you want to project it into another data structure and you would like to know how large it should be. Have you ever considered how ToArray works on an IEnumerable? Well, think about it now. If the IEnumerable cannot be cast to ICollection - which does export a Count - or something similar, then a buffer has to be allocated, data copied, the buffer increased as more data is coming, then copying the data from the buffer into an array, now that we know its final size. It's basically doing… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town