Obtain fields in Primary Index

How do I get the fields present within the Primary Index?

In DictTable, there is only getPrimaryIndex() and getPrimaryField()

In DictIndex, is there any way to iterate through the fields contained in it?

The below is a sample code

static void fetPrimaryIndexFields(Args _args)
{
SysDictTable dictTable;
DictIndex dictIndex;
int pkFieldCount, pkFieldIndex, pkFieldId;

dictTable = new SysDictTable(tableNum(InventTableModule));
dictIndex = dictTable.indexObject(dictTable.primaryIndex());
if(dictIndex != null)
{
pkFieldCount = dictIndex.numberOfFields();

for (pkFieldIndex = 1; pkFieldIndex <= pkFieldCount; pkFieldIndex++)
{
pkFieldId = dictIndex.field(pkFieldIndex);
info(fieldId2name(tableNum(InventTableModule), pkFieldId));
}
}
}

Thank you.