> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/game-module-lists/count-methods.md).

# Count() Methods

v4.0

{% 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
