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.
There is no semantic difference. This is just a refinement of the structure with which we must deal.
I cannot quote the source, but I think .Length is a fixed value and can change .Count.
, .Length.
( ) List, .Count.
List
, .Length:
.Length
.Count .Count():
.Count
.Count()
, , , . , , , , Count.
Length - , Count an ICollection one Count() IEnumerable, .
Length
Count
ICollection
Count()
IEnumerable
.
: IEnumerable Count() ( ) , . .
, Framework Design Guidelines ( ). , , , . , .NET, .NET API Java, quirks.
Source: https://habr.com/ru/post/1779378/More articles:SQL: setting condition on the result of an aggregate function - phpDynamically add a stylized tag to an ASP.Net web page - htmlHow to set Chinese character binding file name in C # SmtpClient programming? - c #Is it possible to update a commit in Mercurial? - version-controlSelect all columns except those that have only null values - sqlPartitioning a query by JPA 2 criteria - javaHow to deserialize a soap reaction using multiref in .net? - xml-deserializationInnoSetup Cannot Find My Documents in Win XP Installed on Mac Parallels - windowsswitch function - jqueryStacking sections side by side in CSS - htmlAll Articles