'opposite of nameof (string of variable name to variable) C# [duplicate]

Say I have a List called this_list. If I make a string that says "this_list", how can I turn that string into the actual variable? It should do the opposite of what nameof would do.

List<string> this_list = new List<string> { "wow","amazing" };
string str = "this_list";
// str to this_list somehow


Solution 1:[1]

If this_list is a local variable (like in your example), you can't. Local variable names are lost during compilation.

If this_list is a field or property, you can use Reflection.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Heinzi