@foxyshadis said:
@headhigh said:Why possibly iterate through the collection to get a count?
?????
You
do have to watch out for classes where things like "count" are
implemented by walking the whole goddam class, like the linked lists
they have you make in school. (A paradigm some students unfortunately
take to heart.) Might waste a whole 4 bytes, can't have that.
Well, you don't know how Count is implemented. At least not typically.
Most collection interfaces contain an isEmpty method, or similar, so the whole point is that code like this:
if (collection.Count() == 0) {
...
}
Should really be written as:
if (collection.isEmpty()) {
...
}
Unless you really want to know how many elements there are, you shouldn't ask...
Btw. do you know what time it is?