> For the complete documentation index, see [llms.txt](https://nviasoft.gitbook.io/nviasoft-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nviasoft.gitbook.io/nviasoft-docs/api-reference/item-parsing/getitemcount.md).

# GetItemCount

### int GetItemCount(int lMsgId)

지정한 메시지 ID(lMsgId) 내에 포함된 전체아이템의 개수를 반환합니다. 여러 아이템이 나열된 구조라면 그 개수를 정확히 알려줍니다.

Parameters

<table data-header-hidden><thead><tr><th width="239"></th><th width="109"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td>lMsgId</td><td>int</td><td>아이템 개수를 확인할 대상 메시지 ID</td></tr></tbody></table>

Return Value

<table data-header-hidden><thead><tr><th width="199"></th><th></th></tr></thead><tbody><tr><td><strong>Value</strong></td><td><strong>Description</strong></td></tr><tr><td>>= 0</td><td>성공 (포함된 아이템의 총 개수)</td></tr></tbody></table>

```csharp
void PrintItemStructure(int lMsgId)
{
    // 메시지의 최상위 아이템 개수 확인
    int itemCount = m_gem.GetItemCount(lMsgId);

    if (itemCount >= 0)
    {
        Console.WriteLine($"[MsgID: {lMsgId}] 에는 총 {itemCount}개의 최상위 아이템이 있습니다.");
        
        // 개수만큼 루프를 돌며 세부 정보 파싱 가능
        for (int i = 1; i <= itemCount; i++)
        {
            // m_gem.GetItemInfo(lMsgId, i.ToString(), ...) 등을 활용
        }
    }
}
```


---

# 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 dynamically by asking a question.

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

```
GET https://nviasoft.gitbook.io/nviasoft-docs/api-reference/item-parsing/getitemcount.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.
