Is there a VB.Net equivalent of following C# nameof
usage:
[MyAttribute(nameof(MyProperty))]
public class MyClass<T>
{
private int MyProperty { get; }
}
Note: MyClass is a generic class and MyProperty
is private
.
I can only work out the following code for non-generic class, with Friend
property, otherwise the compiler will complain 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