PropertyInfo.GetValue() ฉันจะจัดทำดัชนีคอลเลกชันด้วยสตริงโดยใช้การสะท้อนใน C# ได้อย่างไร

สมมติว่าฉันมีคลาสซึ่งมีคุณสมบัติ NameValueCollection

public class TestClass
{
    public NameValueCollection Values { get; private set; }

    public TestClass()
    {
        Values = new NameValueCOllection();
        Values.Add("key", "value");
        Values.Add("key1", "value1");
    }
}

ฉันรู้วิธีรับรายการของการรวบรวมค่าโดยใช้ int indexer (ฟังก์ชัน GetProperty() และ GetValue() สามารถทำได้) แต่ฉันจะรับรายการของ NameValueCollection นี้ด้วยคีย์สตริงโดยใช้. netflection ได้อย่างไร


person deff    schedule 19.10.2010    source แหล่งที่มา
comment
ทำไมคุณถึงอยากทำแบบนั้นผ่านการไตร่ตรอง?   -  person explorer    schedule 20.10.2010


คำตอบ (1)


person    schedule
comment
ขอบคุณมาก ฉันพลาดพารามิเตอร์ที่ 2 ของฟังก์ชัน GetValue คือ object[] :) - person deff; 20.10.2010