# How to convert UEnum type to String? C++

**URL:** <https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498>\
**Category:** C++\
**Tags:** UE4-20, unreal-engine, UE4, question, CPP\
**Created:** [August 4, 2022, 6:44pm UTC](https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498 "2022-08-04T18:44:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 4, 2022, 6:44pm UTC](https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498/1 "2022-08-04T18:44:16Z")

</div>

Hello, is this even possible using C++ in ue4 to print all the array elements?  
what is the alternative for `GetEnumeratorUserFriendlyName`?  
I want to print all the elements located in Array, how to do this? unable to figure out how to convert UEnum type to String?

```auto
TArray<EItemType> Arr{};
for (auto& Array : Arr) //Arr is of type UEnum EItemType
		{
			FString Elements = TEXT("Enum Elements: ") + EnumToString(TEXT("EItemType"), static_cast<uint8>(Array));

printf("%s", *Elements); //macro
		}

```

Error

 ![image_2022-08-04_234342710](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/4/f9461d3b3cdfe991abc701aa760208482181a5b1.png)

blueprint

 ![testtransform22](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/4/d/c4d47f5a0f3d32fbaa7771f8ed812d56a3696abc.png)

any help appreciated in my learning progress

---

<div class="post-metadata">

**Author:** ![c0r37py](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/c0r37py/32/559700_2.png) [@c0r37py](https://forums.unrealengine.com/u/c0r37py)\
**Post date:** [August 4, 2022, 9:12pm UTC](https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498/2 "2022-08-04T21:12:43Z")

</div>

you can convert it using the inbuilt function `GetValueAsString()`

```auto
/**
	 * @param EnumeratorValue Enumerator Value.
	 *
	 * @return the string associated with the enumerator for the specified enum value for the enum specified by the template type.
	 */
template<typename EnumType>
	FORCEINLINE static FString GetValueAsString(const EnumType EnumeratorValue)
	{
		// For the C++ enum.
		static_assert(TIsEnum<EnumType>::Value, "Should only call this with enum types");
		return GetValueAsName(EnumeratorValue).ToString();
	}

```

simply call this function under UE\_LOG macro to print all the stored data to console.  
so in your for loop.

```auto
for (auto& Array : Arr)
	{
      UE_LOG(LogTemp, Log, TEXT("The Elements in Array: %s"), *UEnum::GetValueAsString(Array));
	}

```

hope it helps , test it and show me what results now you will have.  
cheers!

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [August 4, 2022, 9:24pm UTC](https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498/3 "2022-08-04T21:24:55Z")

</div>

Just as complement:

> [@c0r37py](#):
>
> `UEnum::GetValueAsString(Array)`

> **[UEnum](https://docs.unrealengine.com/4.27/en-US/API/Runtime/CoreUObject/UObject/UEnum/)**
>
> Reflection data for an enumeration.

---

<div class="post-metadata">

**Author:** ![Alexa.Ki](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/alexa.ki/32/562753_2.png) [@Alexa.Ki](https://forums.unrealengine.com/u/Alexa.Ki)\
**Post date:** [August 4, 2022, 9:25pm UTC](https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498/4 "2022-08-04T21:25:09Z")

</div>

thank you very much sir, this just solved the big issue , Really appreciated 🙂  
the results i have now in the image, perfect as wanted, all the items are generated randomly

 ![image_2022-08-05_021934136](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/2/8/3284dbf58f2d664b7a2d42f8d5c7f8fc8972491d.png)  
now i can spawn them any where in the level using this method Spawn [Actor From Class](https://forums.unrealengine.com/t/how-to-generate-an-actor-from-class-using-c/620166)

thank you very much for big contribution helping me 🙂

---

<div class="post-metadata">

**Author:** ![c0r37py](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/c0r37py/32/559700_2.png) [@c0r37py](https://forums.unrealengine.com/u/c0r37py)\
**Post date:** [August 4, 2022, 9:26pm UTC](https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498/5 "2022-08-04T21:26:43Z")

</div>

welcome, glad I helped )

---

<div class="post-metadata">

**Author:** ![c0r37py](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/c0r37py/32/559700_2.png) [@c0r37py](https://forums.unrealengine.com/u/c0r37py)\
**Post date:** [August 4, 2022, 9:28pm UTC](https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498/6 "2022-08-04T21:28:16Z")

</div>

these wikis are super useful

---

<div class="post-metadata">

**Author:** ![Archifiction](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Archifiction](https://forums.unrealengine.com/u/Archifiction)\
**Post date:** [January 25, 2024, 12:53pm UTC](https://forums.unrealengine.com/t/how-to-convert-uenum-type-to-string-c/621498/7 "2024-01-25T12:53:43Z")

</div>

Just  
`UEnum::GetValueAsString(YourEnum::Value)`
