Why is Visual Studio replacing List <T> .Length with list <T> .Count?

I noticed that if there is a List<T> (or several other types), and I click . , then among the intellisense suggestions I get Length

enter image description here

If I choose Length , what is actually printed is Count

enter image description here

I can understand why this happens, there is no Length property on the List<T> , and if I'm looking for it, I probably want Count . My question is, how does Visual Studio know about this? I don't see anything in the List<T> class or anywhere else that encodes Length as an alias for Count .

+7
c # visual-studio-2015 resharper
source share
1 answer

This is a feature of ReSharper 10.

He integrated the Postfix Templates plugin in this version, and this is one of the endings that it supports (use the correct Length or Count property).

I am pleased to announce that this plugin is now an integral part of ReSharper 10!

On the project page it is indicated:

Length / quantity code completion solves one of the most common errors when working with arrays or collections:

example

+13
source share

All Articles