<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/new-linq-methods-in-net-9-lnamgdnc7" -->

---
title: New LINQ methods in .NET 9 | daily.dev
description: .NET 9 adds three new LINQ methods - Index, CountBy, and AggregateBy - designed to simplify common collection operations. Index replaces manual for-loops or...
canonical: https://daily.dev/posts/new-linq-methods-in-net-9-lnamgdnc7
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: New LINQ methods in .NET 9 | daily.dev
og:description: .NET 9 adds three new LINQ methods - Index, CountBy, and AggregateBy - designed to simplify common collection operations. Index replaces manual for-loops or...
og:url: https://daily.dev/posts/new-linq-methods-in-net-9-lnamgdnc7
og:image: https://api.daily.dev/og/posts/LNaMgdnC7.png
og:image:alt: New LINQ methods in .NET 9
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.

# New LINQ methods in .NET 9

**[NikolaTech](https://daily.dev/sources/nikolatech)** · 5 min read · 0 upvotes · 0 comments

## Summary

.NET 9 adds three new LINQ methods - Index, CountBy, and AggregateBy - designed to simplify common collection operations. Index replaces manual for-loops or Select-with-index patterns for tracking element positions. CountBy combines GroupBy and Count into a single call for counting occurrences. AggregateBy merges grouping and aggregation (e.g., summing values per category) into one step. Benchmarks show CountBy and AggregateBy are significantly faster and allocation-free compared to traditional GroupBy/Select chains, thanks to internal use of CollectionsMarshal.GetValueRefOrAddDefault, while Index shows only marginal improvement.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nikolatech.net/blogs/new-linq-methods-in-dotnet9>

## Questions this post answers

### What new LINQ methods were added in .NET 9?

.NET 9 introduces three new LINQ methods: Index, CountBy, and AggregateBy. Index lets you iterate a collection while tracking each element's position without manual counters. CountBy combines GroupBy and Count into a single call to count occurrences by key. AggregateBy merges grouping and aggregation into one step, such as summing values per category, replacing a GroupBy followed by Select.

_Developers tracking .NET 9 API additions can follow LINQ and C# updates on daily.dev._

### Are CountBy and AggregateBy in .NET 9 faster than GroupBy with Select?

Yes, benchmarks show CountBy and AggregateBy are substantially faster and allocate no memory, unlike the traditional GroupBy combined with Select approach which allocates around 144-152 bytes per call. AggregateBy ran at about 5 nanoseconds versus 25 nanoseconds for GroupBy+Select+Sum, and CountBy ran at about 2.5 nanoseconds versus 24 nanoseconds for GroupBy+Select+Count. The speed gain comes from internal use of CollectionsMarshal.GetValueRefOrAddDefault, which avoids allocation overhead.

_Engineers optimizing LINQ-heavy code can compare collection method performance via daily.dev._

## Similar posts on daily.dev

- [LINQ in C\#](https://daily.dev/posts/linq-in-c--eoxkvhpkr) · C\# Corner · 36 upvotes · 2 comments
- [30 LINQ Interview Questions That Actually Get Asked in 2026](https://daily.dev/posts/30-linq-interview-questions-that-actually-get-asked-in-2026-z9bazqvrc) · Code with Mukesh · 13 upvotes · 1 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/new-linq-methods-in-net-9-lnamgdnc7)

```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":"New LINQ methods in .NET 9","url":"https://daily.dev/posts/new-linq-methods-in-net-9-lnamgdnc7","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/new-linq-methods-in-net-9-lnamgdnc7"},"datePublished":"2026-10-04T13:05:56.551Z","dateModified":"2026-10-04T13:12:27.320Z","description":".NET 9 adds three new LINQ methods - Index, CountBy, and AggregateBy - designed to simplify common collection operations. Index replaces manual for-loops or...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9c3d18eac998128089ea3c21aceea272?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9c3d18eac998128089ea3c21aceea272?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"NikolaTech","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":"NikolaTech","logo":"https://media.daily.dev/image/upload/s--1h2fO6FL--/f_auto,q_auto/v1791119050/logos/nikolatech?_a=BAMAMicg0","url":"https://daily.dev/sources/nikolatech"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/new-linq-methods-in-net-9-lnamgdnc7","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,.net,c#","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"NikolaTech","item":"https://daily.dev/sources/nikolatech"},{"@type":"ListItem","position":3,"name":"New LINQ methods in .NET 9"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/new-linq-methods-in-net-9-lnamgdnc7#faq","mainEntity":[{"@type":"Question","name":"What new LINQ methods were added in .NET 9?","acceptedAnswer":{"@type":"Answer","text":".NET 9 introduces three new LINQ methods: Index, CountBy, and AggregateBy. Index lets you iterate a collection while tracking each element's position without manual counters. CountBy combines GroupBy and Count into a single call to count occurrences by key. AggregateBy merges grouping and aggregation into one step, such as summing values per category, replacing a GroupBy followed by Select. Developers tracking .NET 9 API additions can follow LINQ and C# updates on daily.dev."}},{"@type":"Question","name":"Are CountBy and AggregateBy in .NET 9 faster than GroupBy with Select?","acceptedAnswer":{"@type":"Answer","text":"Yes, benchmarks show CountBy and AggregateBy are substantially faster and allocate no memory, unlike the traditional GroupBy combined with Select approach which allocates around 144-152 bytes per call. AggregateBy ran at about 5 nanoseconds versus 25 nanoseconds for GroupBy+Select+Sum, and CountBy ran at about 2.5 nanoseconds versus 24 nanoseconds for GroupBy+Select+Count. The speed gain comes from internal use of CollectionsMarshal.GetValueRefOrAddDefault, which avoids allocation overhead. Engineers optimizing LINQ-heavy code can compare collection method performance via daily.dev."}}]}
```

