从Type类构造函数获取成员名称

时间:2018-08-02 08:40:06

标签: c# oop reflection

是否可以从类型的构造函数中从类型成员获取Name? 例如:

包含成员属性的类

public class ClassA
{
    public int X {get; set; }
    public GenericType<ClassA> iNeedThisName {get; set;}
}

GenericType的类定义,我希望从该类访问构造函数中的值

public class GenericType<T>
{
    private _iNeedThisNameValue = null;
    public GenericType()
    {
        _iNeedThisNameValue = this.Get"IneedThisName()".ExtensionMethod();
    }
    public string idLikeToDefault { get; set;} = _iNeedThisNameValue;
}

0 个答案:

没有答案