To get the actual name of the property, just from having access to the class, you can use the following:
Type studentType = typeof(Student);
PropertyInfo[] AllStudentProperties = studentType.GetProperties();
If you know the name you're looking for and just need access to the property itself, use:
Type studentType = typeof(Student);
PropertyInfo StudentProperties = studentType.GetProperty("StudentName");
Once you have the PropertyInfo
, simply use PropertyInfo.Name
, which will give the string representation.
If after this you wan't the value, you're going to have to have an instantiated class to get the value. Other than this, if you use a static
property, you can pull the value without instantiating it.