public static class Demo
{
public static void MapGrpcService<TService>() where TService : class
{
Console.WriteLine(typeof(TService));
}
public static void Hello<T>(string name)
{
Console.WriteLine(typeof(T));
Console.WriteLine(name);
}
}
class Program
{
static void Main(string[] args)
{
Assembly assembly = Assembly.GetExecutingAssembly();
Type type = assembly.GetType("every_FanShe.Demo");
type.GetMethod("Hello").MakeGenericMethod(typeof(Demo)).Invoke(null, new[] { "wocao" });
typeof(Demo).GetMethod("Hello").MakeGenericMethod(typeof(Demo)).Invoke(null,new[] { "wocao"});
Console.Read();
}
}
C# 反射调用类型中的方法,两种方式
原创mb6100f4ef45bc6 ©著作权
©著作权归作者所有:来自51CTO博客作者mb6100f4ef45bc6的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python中两种网络编程方式:Socket和HTTP协议
本文将介绍Python中两种主要的网络编程方式:Socket编程和基于HTTP协议的网络编程,并通过实际案例来演示它们的应用。
Python 网络编程 Socket HTTP协议 -
C#中两种生成验证码的方式
1、WPF使用 DrawingVisual 绘制验证码首先新建一个用户控件,封装生成的验证码图片XAML样式<Grid Load
c# 验证码 画布 System Windows -
C语言调用so动态库的两种方式
文章目录1.方式1:类似静态库的调用(使用头文件)2.使用dlopen/dlsum动态加载动态库(不使用头文件)3.so动态库中调用so动态库1
算法 数据库 排序算法 动态库 #include -
C#两种创建快捷方式的方法
C#两种创建快捷方式的方法
快捷方式 c# hive html JAVA