Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: C# クラスのプロパティを動的に読み取るにはどうすればよいですか?
名前の文字列のみを使用して、クラス メンバーの値を取得する必要があります。リフレクションを使用する必要があると思いますが、その方法がよくわかりません。手伝って頂けますか?
public class Foo { public string A { get; set; } } public class Example { public void GetPropertyValueExample() { Foo f = new Foo(); f.A = "Example"; var val = f.GetType().GetProperty("A").GetValue(f, null); } }