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,

Hi,

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?

Thanks

Hi @Srini84,

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,

2 Likes

Hey @Srini84 , I have the same issue. Did you find the solution for this?

Also still looking for a way to do this. It’s not a very frequent use case but sometimes for my custom libraries I want to log the name of the variable that is being passed in to the arguments, and the methods for doing this in C# don’t work in UiPath as aarivat mentioned.

1 Like