C# 反射

        public static void CallPrivateMethod(object instance, string name, params object[] param)
        {
            BindingFlags flag = BindingFlags.Instance | BindingFlags.NonPublic;
            Type type = instance.GetType();
            MethodInfo method = type.GetMethod(name, flag);
            method.Invoke(instance, param);
        }

转自 https://segmentfault.com/q/1010000007608935?_ea=1398469

            var request = (HttpWebRequest)WebRequest.Create("https://");

            CallPrivateMethod(request, "SetSpecialHeaders", "AAAAAAAA", DateTime.Now.ToString("R"));

 

上一篇:加载 unity的布局文件


下一篇:2019-11-29-WPF-禁用实时触摸