【发布时间】:2013-03-11 07:25:48
【问题描述】:
我有课
public class News : Record
{
public News()
{
}
public LocaleValues Name { get; set; }
public LocaleValues Body;
}
在我的LocaleValues 课程中,我有:
public class LocaleValues : List<LocalizedText>
{
public string Method
{
get
{
var res = System.Reflection.MethodBase.GetCurrentMethod().Name;
return res;
}
}
}
当我进行这样的调用时,我需要 Method 属性来返回 Name 属性名称的字符串表示形式:
var propName = new News().Name.Method;
我怎样才能做到这一点?感谢您的宝贵时间!
【问题讨论】:
-
我认为这不可能。
LocaleValues的实例如何知道它是通过名为Name的属性“找到”的?您的代码可能每次都返回get_Method?也许你应该让你的Namesetter 修改它接受的参数(value)来记录名字?
标签: c# system.reflection