<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/c-tip-ienumerable-vs-icollection-and-why-it-matters-fzyyns63v" -->

---
title: C# Tip: IEnumerable vs ICollection, and why it matters
description: Explains the difference between IEnumerable&lt;T&gt; and ICollection&lt;T&gt; in C#, and why choosing the right return type matters when designing public interfaces....
canonical: https://daily.dev/posts/c-tip-ienumerable-vs-icollection-and-why-it-matters-fzyyns63v
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: C# Tip: IEnumerable vs ICollection, and why it matters | daily.dev
og:description: Explains the difference between IEnumerable&lt;T&gt; and ICollection&lt;T&gt; in C#, and why choosing the right return type matters when designing public interfaces....
og:url: https://daily.dev/posts/c-tip-ienumerable-vs-icollection-and-why-it-matters-fzyyns63v
og:image: https://api.daily.dev/og/posts/FZYYNS63v.png
og:image:alt: C# Tip: IEnumerable vs ICollection, and why it matters
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# C# Tip: IEnumerable vs ICollection, and why it matters

**[Code4IT](https://daily.dev/sources/code4it)** · 6 min read · 0 upvotes · 0 comments

## Summary

Explains the difference between IEnumerable<T> and ICollection<T> in C#, and why choosing the right return type matters when designing public interfaces. IEnumerable only allows iteration, while ICollection adds and removes items, giving consumers more control. The piece argues against defaulting to returning List<T> from library interfaces, showing how returning IEnumerable instead lets you swap internal implementations (e.g., a custom enumerable class) without breaking consumers, while also preventing external code from tampering with internal state.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.code4it.dev/csharptips/ienumerable-vs-icollection>

## Questions this post answers

### Should I return List<T> or IEnumerable<T> from a public C# interface method?

Prefer IEnumerable<T> when consumers only need to iterate results, since it hides the concrete implementation and lets you swap internal classes later without breaking changes. Returning List<T> or ICollection<T> exposes add/remove capabilities that let external consumers tamper with data they shouldn't modify, which hurts encapsulation in shared libraries.

_daily.dev surfaces practical API design trade-offs like this for developers shaping public C# libraries._

### What is the difference between IEnumerable<T> and ICollection<T> in C#?

IEnumerable<T> only supports looping through items via GetEnumerator, with no way to add or remove elements. ICollection<T> extends IEnumerable<T> and adds Count, Add, Remove, Clear, and Contains, giving full control over modifying the collection's contents, which matters when deciding how much freedom to give API consumers.

_Developers comparing C# collection interfaces can track these distinctions on daily.dev._

## Similar posts on daily.dev

- [Iterator vs Observer Pattern in C\#: Key Differences Explained](https://daily.dev/posts/iterator-vs-observer-pattern-in-c-key-differences-explained-anctjsi0z) · We Are .NET · 5 upvotes · 0 comments
- [LINQ in C\#](https://daily.dev/posts/linq-in-c--eoxkvhpkr) · C\# Corner · 36 upvotes · 2 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/c-tip-ienumerable-vs-icollection-and-why-it-matters-fzyyns63v)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"C# Tip: IEnumerable vs ICollection, and why it matters","url":"https://daily.dev/posts/c-tip-ienumerable-vs-icollection-and-why-it-matters-fzyyns63v","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/c-tip-ienumerable-vs-icollection-and-why-it-matters-fzyyns63v"},"datePublished":"2026-10-04T13:05:28.839Z","dateModified":"2026-10-04T13:10:14.214Z","description":"Explains the difference between IEnumerable<T> and ICollection<T> in C#, and why choosing the right return type matters when designing public interfaces....","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8e05ce0b57d062025836ade75d0d2855?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8e05ce0b57d062025836ade75d0d2855?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Code4IT","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Code4IT","logo":"https://media.daily.dev/image/upload/s--OaaG4G10--/f_auto,q_auto/v1791119049/logos/code4it?_a=BAMAMicg0","url":"https://daily.dev/sources/code4it"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/c-tip-ienumerable-vs-icollection-and-why-it-matters-fzyyns63v","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"architecture,.net,c#","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Code4IT","item":"https://daily.dev/sources/code4it"},{"@type":"ListItem","position":3,"name":"C# Tip: IEnumerable vs ICollection, and why it matters"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/c-tip-ienumerable-vs-icollection-and-why-it-matters-fzyyns63v#faq","mainEntity":[{"@type":"Question","name":"Should I return List<T> or IEnumerable<T> from a public C# interface method?","acceptedAnswer":{"@type":"Answer","text":"Prefer IEnumerable<T> when consumers only need to iterate results, since it hides the concrete implementation and lets you swap internal classes later without breaking changes. Returning List<T> or ICollection<T> exposes add/remove capabilities that let external consumers tamper with data they shouldn't modify, which hurts encapsulation in shared libraries. daily.dev surfaces practical API design trade-offs like this for developers shaping public C# libraries."}},{"@type":"Question","name":"What is the difference between IEnumerable<T> and ICollection<T> in C#?","acceptedAnswer":{"@type":"Answer","text":"IEnumerable<T> only supports looping through items via GetEnumerator, with no way to add or remove elements. ICollection<T> extends IEnumerable<T> and adds Count, Add, Remove, Clear, and Contains, giving full control over modifying the collection's contents, which matters when deciding how much freedom to give API consumers. Developers comparing C# collection interfaces can track these distinctions on daily.dev."}}]}
```

