.net naming convention: is there a semantic difference between length and graph?

To get the number of subelements in dotnet, sometimes I need to set the Lenght property, sometimes I need to set the Count property.

Is there any reason for the difference?

Example:

   int[] a; if (a.Length == 0) ....
   IList<int> b; if (b.Count == 0) ....

Note The difference between IEnumerable Count () and Length sounds similar, but does not correspond to the semantics between length and graph.

+3
source share
5 answers

There is no semantic difference. This is just a refinement of the structure with which we must deal.

+2
source

I cannot quote the source, but I think .Length is a fixed value and can change .Count.

, .Length.

( ) List, .Count.


, .Length:

.Count .Count():

  • , ( )
+5

, , , . , , , , Count.

+3

Length - , Count an ICollection one Count() IEnumerable, .

.

: IEnumerable Count() ( ) , . .

+2

, Framework Design Guidelines ( ). , , , . , .NET, .NET API Java, quirks.

+1
source

Source: https://habr.com/ru/post/1779378/


All Articles