Is there a way to get the name of a method as text, strongly typed?
private void Do()
{
}
private Something ReturnSomething()
{
return new Something();
}
private void GenerateCode()
{
// ----------------
// Do().GetName;
// ReturnSomething().GetName;
// ----------------
// How to do this?
}
I tried something like Do().ToString();
or by using Reflection
, but I couldn't find something that worked.
使用nameof运算符
string name = nameof(Do);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.