当前位置:网站首页>C get the class name or method name of the caller
C get the class name or method name of the caller
2022-04-22 22:51:00 【Attacking brother pea】
private static String? initClassName()
{
StackTrace trace = new StackTrace();
var stringBuilder = new StringBuilder();
// GetFrame() Get which class is called
// 1: first floor , That is, the current class
// 2: The second floor , That is, call the class
// 3: The third level , Multilayer call class
// n: And so on
Type? type = trace.GetFrame(2)?.GetMethod()?.DeclaringType;
// Get is called by the method in the class
string? method = trace.GetFrame(2)?.GetMethod()?.ToString();
if (type != null)
{
stringBuilder.Append(" - ");
stringBuilder.Append(type);
}
if (method != null)
{
stringBuilder.Append(" - ");
stringBuilder.Append(method);
}
Console.WriteLine(" Get the class name :" + stringBuilder);
return stringBuilder.ToString();
}
版权声明
本文为[Attacking brother pea]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222216220268.html
边栏推荐
- What is the magic of moonbirds NFT, which became popular overnight?
- 九九乘法表代码
- 基于Multisim的波形发生器
- Pangolin installation error: Make: * * * there are no rules to create the target "pypangolin_pip_install". stop it.
- OJ每日一练——下落又弹起的小球
- 邀请你参与字节跳动 UME 插件开发竞赛
- Acl2022 | using Chinese language hierarchy heterogeneity map to strengthen the pre training language model
- Multithreading advanced (7) -- optimistic lock and pessimistic lock
- OJ每日一练——求平方根的迭代方法
- What is the function of timestamp and how to apply for it?
猜你喜欢

CVPR 2022:微笑识别也带性别歧视?浙大武大联合蚂蚁Adobe搞了个公平性提升框架

交换机的接口有哪些?一文带你记住其名称及作用

【洛谷】P1162 填涂颜色(bfs)

Catering industry cashier system source code, C # Net + MSSQL WPF

A journey to C by Xiao Sai Mao -- first understanding of C language (3)

41.0:GemBox. Spreadsheet|. Document|. Pdf|. Presentation

吴恩达-深度学习微课-第四课

时间戳有什么作用,如何申请?

0-1 knapsack problem explanation & leetcode related topic summary

js的正则表达式
随机推荐
L1-070 吃火锅 (15 分)
GBase 8s V8. 8 SQL Guide: Tutorial - 6.2.2 (1)
scanpy find resolution
Flutter 一文搞定图片选择和图片上传
数组取反-数组和字符串取反都行
appinventor2在window上搭建步骤
GBase 8s V8. 8 SQL Guide: Tutorial - 6.1.2 (2)
每日CISSP认证常错题(2022年4月22日)
L1-069 胎压监测 (15 分)
对话杨炯纬,快体现在抓住“红利”上,实际上TO B公司应该跑得慢一点
Lecture recording and broadcasting | subgraph matching algorithm in graph database - Zou Lei
Wu Enda - deep learning micro course - Lesson 4
Saiweidian broke on the first day of listing: the market value evaporated by more than 1.5 billion yuan, and the business scale lost slightly
邀请你参与字节跳动 UME 插件开发竞赛
RPC详解
Graph and numerical representation of knowledge map of knowledge representation
等价多米诺骨牌对的数量-c语言实现
GBase 8s V8.8 SQL 指南:教程-6.2.1(3)
js的正则表达式
哪怕 30 年寒窗苦讀,也有可能離財富很遠……