C#: how to get an object by the name stored in String?

后端 未结 4 1779
南方客
南方客 2020-12-06 21:44

is it possible in C# to get an object by name?

i.e. get this.obj0 using

string objectName = \"obj0\";
executeSomeFunctionOnObject(this.someLoadObject         


        
4条回答
  •  猫巷女王i
    2020-12-06 21:49

    No, not all objects have a Name property (for starters).

    But you can store objects of interest in a Dictionary. You could also get a Control by name, the exact method would depend on the UI library.

提交回复
热议问题