在VB.Net中是否有以下C#nameof
用法的等效项:
[MyAttribute(nameof(MyProperty))]
public class MyClass<T>
{
private int MyProperty { get; }
}
注意:MyClass是泛型类,而MyProperty
是private
。
我只能为具有Friend
属性的非泛型类编写以下代码,否则编译器会抱怨MyClass.MyProperty is not accessable in this context because it is 'Private'
:
<MyAttribute(NameOf(MyClass.MyProperty))>
Public Class MyClass
Private m_MyProperty As Integer
Friend ReadOnly Property MyProperty As Integer
Get
Return m_MyProperty
End Get
End Property
End Class