I'm trying to create a function that when a property is passed to it as a parameter, it returns the name used to define the property as a string. For example,
Shared Function PropertyToStr(Propert As Object)
'Code to get property name and return it as a string goes here
End Function
Providing that First_Name
is a the name of a property, defined like:
Property First_Name as String
The function should work like:
Dim str as String = PropertyToStr(First_Name) ' Resulting in str = "First_Name"
Note I ONLY want in this function to return the property name "First_Name", and not "MyClass.First_Name" for example.
I have found other examples of similar code to my function I require written in c# yet I have not been able to replicate their use of the MemberExpression in VB.Net
Getting sub property names strongly typed