using System.Reflection; private void RunReflection() { MethodInfo hogeMethod = typeof(HogeStaticClass).GetMethod("HogeMethod", BindingFlags.NonPublic | BindingFlags.Static); object[] param = new object[] { 5, null }; hogeMethod.Invoke(this, param); Console.WriteLine(param[1]); } class HogeStaticClass { private static void HogeMethod(int n, out int m) { m = n + 1; } }
逓送(ていそう)
https://kotobank.jp/word/%E9%80%93%E9%80%81-574481
通信や荷物などを人から人へ順送りすること。
特に情報を人から人へと順送りで伝えることは「逓伝(ていでん)」と呼ぶ。
C#のリフレクションで private static メソッドを呼び出し、out引数を受け取る方法
using System.Reflection; private void RunReflection() { MethodInfo hogeMethod = typeof(HogeStaticClass).GetMethod("HogeMethod", BindingFlags.NonPublic | BindingFlags.Static); object[] param = new object[] { 5, null }; hogeMethod.Invoke(this, param); Console.WriteLine(param[1]); } class HogeStaticClass { private static void HogeMethod(int n, out int m) { m = n + 1; } }
逓送(ていそう)
https://kotobank.jp/word/%E9%80%93%E9%80%81-574481
通信や荷物などを人から人へ順送りすること。
特に情報を人から人へと順送りで伝えることは「逓伝(ていでん)」と呼ぶ。