# Count() Methods

{% hint style="info" %}
Example code here is from `GameStatList.cs`, though similar methods are on other list classes as well.

Methods for specific list types are below.
{% endhint %}

{% hint style="info" %}
The common methods can be found in `GameModuleListExtensions.cs`
{% endhint %}

## `Count()`

You can count the items in the list. Each Game Modules list has a `List<>` in it, so while you could call `gameModulesList.list.Count`, we've added these methods.

```csharp
// Count all in the list
Debug.Log($"There are {gameStatList.Count()} stats in the gameStatList.");

// Add in a uid to only count the objects with that uid
Debug.Log($"There are {gameStatList.Count(uid)} stats in the list with " +
                      $"the named {statsRepository.GetByUid(uid).objectName}");
                      
// Count the number of a specific objectType
var objectType = "Weapon Skill";
Debug.Log($"There are {gameStatList.CountObjectType(objectType)} {objectType} objects " +
                      $"in the list.");
                      
// Get the number of unique objects, based on the uid
Debug.Log($"There are {gameStatList.CountUnique} unique stats in the list");

// Get the number of duplicates, excluding the first of each
Debug.Log($"There are {gameStatList.CountDuplicates()} additional duplicate items " +
                      $"beyond the first of each uid");
                      
// Get the number of duplicates of a specific objectType, excluding the first of each
Debug.Log($"There are {gameStatList.CountDuplicatesOfType(objectType)} additional " +
                      $"duplicate items of type {objectType} beyond the first of each");

// Get the number of different objectTypes
Debug.Log($"There are {gameStatList.CountTypes()} objectTypes in the list");
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/game-module-lists/count-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
