# UE Reflection - how to get Type of TArray elements?

**URL:** <https://forums.unrealengine.com/t/ue-reflection-how-to-get-type-of-tarray-elements/354289>\
**Category:** Rendering\
**Tags:** reflection, unreal-engine, UE4, CPP, question\
**Created:** [April 15, 2016, 12:36pm UTC](https://forums.unrealengine.com/t/ue-reflection-how-to-get-type-of-tarray-elements/354289 "2016-04-15T12:36:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_590cb5931](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_590cb5931](https://forums.unrealengine.com/u/anonymous_user_590cb5931)\
**Post date:** [April 15, 2016, 12:36pm UTC](https://forums.unrealengine.com/t/ue-reflection-how-to-get-type-of-tarray-elements/354289/1 "2016-04-15T12:36:57Z")

</div>

Hello.  
How to get Type of TArray elements with UE reflection?  
For example, I have some array:

```
    UMySaveGame* save = Cast<UMySaveGame>(UGameplayStatics::CreateSaveGameObject(UMySaveGame::StaticClass()));

    TArray<FString> sa;
sa.Add(TEXT("TEXT0"));
sa.Add(TEXT("TEXT1"));
sa.Add(TEXT("TEXT2"));
save->MyStrArrProp = sa;

```

and I want to access it with the reflection:

```
UClass* SourceObjectClass = save->GetClass();
	TMap<FString, UProperty*> Props;
	for (TFieldIterator<UProperty> PropIt(SourceObjectClass, EFieldIteratorFlags::SuperClassFlags::IncludeSuper);
	PropIt; ++PropIt)
	{
		Props.Add(*PropIt->GetNameCPP(), *PropIt);
	}
for (auto p : Props) {

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green,
				TEXT("PROP NAME: ") + p.Key +
				TEXT(" - TYPE: ") + p.Value->GetCPPType()
				//TEXT(" - VALUE: ") + (*ValuePtr)
				);
}

```

It shows only **TArray** for `p.Value->GetCPPType()` . But how to check, what type of values of that TArray?  
Ie, it can be, for example `TArray`.

Thank you!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_590cb5931](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_590cb5931](https://forums.unrealengine.com/u/anonymous_user_590cb5931)\
**Post date:** [April 15, 2016, 1:13pm UTC](https://forums.unrealengine.com/t/ue-reflection-how-to-get-type-of-tarray-elements/354289/2 "2016-04-15T13:13:46Z")

</div>

Solution is very simple, as it turned out:

```
for (auto p : Props) {
   if (p.Value->GetCPPType().Equals(TEXT("TArray"))) {
       UArrayProperty* ArrayProp = Cast<UArrayProperty>(p.Value);

       GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green,
          	TEXT("PROP NAME: ") + p.Key +
                TEXT(" - TYPE: ") + ArrayProp->Inner->GetClass()->GetName()
		);
   }
}

```

---

<div class="post-metadata">

**Author:** ![grigosant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@grigosant](https://forums.unrealengine.com/u/grigosant)\
**Post date:** [November 28, 2024, 4:11pm UTC](https://forums.unrealengine.com/t/ue-reflection-how-to-get-type-of-tarray-elements/354289/3 "2024-11-28T16:11:01Z")

</div>

I tried this, but unfortunatelly it returned _StrProperty_ for `TArray<FString>`  
i found that the function `GetCPPType()`has parameter to write container’s type, so it can be

```auto
FString ContainerTypeText;
ArrayProperty->GetCPPType(&ContainerTypeText, 0);

```

(return `<FString>`)
