Can I use switch case in C++ with FString?

Hi, I’m making XML parsing code with FXmlNode.
I want to iterate through GetChildrenNodes(), and use switch-case with FString which is return value of FXmlNode::GetTag().
Is there someway to do that? Or should I use

if (Tag == TEXT("XX") ..
else if (Tag == TEXT("YY"));

Thanks.

Well no, it is a limitation from FString, and every string type in UE, but you can use a trick, you can make a TArray with FNames from your FStrings, then set a number for everyone, and then get every number in the switch, but to be honest just use if and else, is less annoying.

FString hey = "hey";
FName ConvertedFString = FName(*hey);
	
switch (ConvertedFString.GetNumber())
{
	case 1:
	{

	}
}
1 Like

Thanks. It helps.