我有这些字符串数组:
string[] BayReplyArray1 = new string[30];
string[] BayReplyArray2 = new string[30];
string[] BayReplyArray3 = new string[30];
... up to 10
Run Code Online (Sandbox Code Playgroud)
我想在这样的循环中访问它们:
for (int i = 1; i < 11; i++)
{
BayReplyArray[i] = "test";
}
Run Code Online (Sandbox Code Playgroud)
它说BayReplyArray在当前上下文中不存在.我可以看出为什么它很困惑,但我怎么能做到这一点?
我试图使用反射和我见过的所有例子说,这应该工作。我正在尝试获取如下所示的PortName属性。
返回null:
var port = this.GetType().GetProperty("PortName", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty);
Run Code Online (Sandbox Code Playgroud)