Get the name of variable as string

Hi everyone,

I tried, wihtout succes, to find an system to get the variable name, as string.
For exemple:
int Index = 5;
log message of index name = index

For this i found Memberinfo and MemberType, but both doesn’t work, for exemple when i do :
System.Reflection.MemberTypes.GetName(index.GetType, index)
That return “Type provided must be an enum”.

I feel like i’m close of the solution, but i need an little help for end this :slight_smile:

Best Regards,


can you tell what you are trying to do. from this it is unclear that are you trying to find a index or just to display the variable?


Hi @ksrinu070184,

I simply want to return the name of the variable.
And if it’s possible in every Type, witch mean finding a way for getting the name of the variable even if it’s an string, an int, Datatable or other.

Something like NameofVariable(myvariable) who return “myvariable” and not his value (by the way, nameOf(), doesn’t work neither on uipath)

I hope it’s a little more clear now :smiley:

Best Regards,

1 Like