Well, this is a tipical situation when you may say “it’s easy”.
And it is, indeed, but you have to be aware of a couple of “small” issues.
First of all, you know that the SPListItemCollection class exposes a count property, you invoke it and voila, you get the total numebr of items contained within a SharePoint list.
But… be careful, because you are fetching *all* items, possibly causing a hige load on the server (SharePoint and SQL Server).
A better approach would be using the ItemCount property of the SPList class.
Which is what I would suggest, with a little gotcha: ItemCount returns exactlt what the name suggests, i.e. the count of all list items, and doing so it *does not* apply any sort of security trimming. In other words, if the code is run within the context of a user who has the rights to view only 5 out of a total of 10 list items, this property returns 10.
Pay a lot attention when you are looping or indexing an SPListItemCollection this way!