Windows Store apps开发[34].NET 4.5 获取Caller Function的信息(Caller Attributes)
来源:互联网 发布:看片同声翻译软件 编辑:程序博客网 时间:2024/06/06 13:08
注:本文由BeyondVincent(破船)原创首发
转载请注明出处:BeyondVincent(破船)@DevDiv.com
更多内容请查看下面的帖子
[DevDiv原创]Windows 8 开发Step by Step
在调试代码时,大家都会有这样的一个问题“谁调用了我的这个函数?”在很多情况下,知道了调用函数,是开始解决bug的第一步。到目前为止,主要方法是:在Visual Studio中,看看看调用栈信息,或者调试器。在.NET 4.5中,添加了一个新特性:一个函数可以知道它被谁调用了,调用函数的信息包括:函数名、文件名和调用所在的行。开发者现在可以使用这些信息来提供有用的调试信息了。这个特性所在名称空间为:System.Runtime.CompilerServices。下面是一个使用示例:【Windows 8 store apps开发中】
public void Method([CallerMemberName] string name = "", [CallerFilePath] string file = "", [CallerLineNumber] int line = 0){ Debug.WriteLine(name); Debug.WriteLine(file); Debug.WriteLine(line);}
本篇文章的内容虽然少,但是小小功能,非常有用。祝你调戏代码成功!
- Windows Store apps开发[34].NET 4.5 获取Caller Function的信息(Caller Attributes)
- Function.caller
- caller property of function
- Windows Store apps开发[15]如何获取设备当前位置
- Windows Store apps开发[35]如何创建自己的Windows Store账号来提交Apps
- arguments的caller,callee
- javascript的caller机制
- callee & caller的区别
- Windows Store apps开发[3]应用程序栏(AppBar)的使用
- Windows Store apps开发[5]导航栏(AppBar)的使用
- Windows Store apps开发[37]调用自己的异步函数
- Windows Store apps开发[45]修改ProgressBar的颜色
- Windows Store apps开发[48]MessageDialog的使用
- Windows Store apps开发[45]修改ProgressBar的颜色
- [Javascript Function] Arguments, call(), apply(), caller(), callee()
- JS Function.caller 和 arguments.callee学习
- Windows Store apps开发[31]Windows Store中企业账号和个人账号的区别
- Windows Store apps开发[25]Metro style apps改名为Windows Store apps
- [转]骨骼蒙皮动画(Skinned Mesh)的原理解析(一)
- 获取文件字节数组byte[]
- windows server 2008 x6 System.Runtime.InteropServices.COMException (0x800A03EC)處理方法
- 联讯证券宏观及固定收益高等剖析师
- 卡特兰数
- Windows Store apps开发[34].NET 4.5 获取Caller Function的信息(Caller Attributes)
- Windows Phone 上的触控手势
- iOS method、selector区别
- 数据库常用的SQL语句(三)数据的操作
- [Linux][2012-09-27] Linux nm && ldd 命令
- linux crontab命令参数及用法详解--linux自动化定时任务cron
- 链表相邻元素翻转,如a->b->c->d->e->f-g,翻转后变为:b->a->d->c->f->e->g
- highcharts日期型X轴示例2-采用arryList输出categories和确定x值
- 如何在Eclipse中用JDBC连接Sql Server 2005