【发布时间】:2019-02-05 23:20:44
【问题描述】:
给定一些看起来像这样的对象:
public class MyObject
{
public int thing_1 { get; set; }
public int thing_2 { get; set; }
public int thing_3 { get; set; }
....
public int thing_100 { get; set; }
}
我该怎么做这样的事情:
int valueINeed = GetValue(MyObject, 2);
哪个会调用...(这就是我需要帮助的地方)...
private int GetValue(MyObject, int find)
{
return MyObject.thing_[find];
}
如果可以避免的话,我宁愿不要在 Switch 中逐行进行。
【问题讨论】:
-
好点。我会清理的
标签: c#