如何获取方法名称 win 8 app [英] How to get method name win 8 app

查看:23
本文介绍了如何获取方法名称 win 8 app的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 win 8(WinRT) 应用程序中获取当前方法名称......在 wp7 早期我们可以使用 System.Reflection.MethodBase.GetCurrentMethod().Name 但它不再存在了,谢谢

How to get the current method name in win 8(WinRT) app ... earlier in wp7 we could use System.Reflection.MethodBase.GetCurrentMethod().Name but its not there anymore thanks

推荐答案

是的,.NETCore 缺少很多这样的东西......甚至没有让我开始GetTypeInfo() !但也许一个务实的解决方法是让编译器为你做这件事?

Yes, .NETCore lacks a lot of such things... and don't even get me started on GetTypeInfo() ! But perhaps a pragmatic workaround is to get the compiler to do it for you?

string CallerName([CallerMemberName]string caller = "")
{
    return caller;
}
...
string name = CallerName();

这篇关于如何获取方法名称 win 8 app的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆