3
Answers

Syntax for referring to variable name by string?

Ask a question
wadeontheweb

wadeontheweb

20y
2.8k
1
If I have member called: this.m_yodasShoeSize and I want to refer to it by a string with something like: this."m_" + "yodasShoeSize" is there syntax in c# for that. I expected something like: this["m_" + "yodasShoeSize"] or this[eval("m_" + "yodasShoeSize"); Also, is there a name for what I'm talking about here? I'm not sure what to call this feature, although I have seen it available in a few languages.

Answers (3)