If you need to know the total items in the list, how do you write code? The usual way to write code is shown below:
Code Snippet 1: Usual (not suggested) way to get items count
However this will fetch all the records from database and apply the count in memory.
SharePoint object model provides an easiest way to find the items count without fetching all records and you can use the following code snippet to do so:
Code Snippet 2: Suggested way to get items count