This is a handy function that you can use if you are using Reflection and have a property name, for example, "
myPropertName" and you want it to be a label or a heading formatted like "My Property Name".
Sometimes I use Reflection to create columns in basic administration functions in an application where there is no real business logic behind the objects. Things like type and status for example.
Using the code
Pretty straightforward. Just send a property name to it like
MyPropertyName and it will turn it into "My Property Name".
private string createDisplayText(string propertyName)
StringBuilder builder = new StringBuilder();
character = char.ToUpper(propertName);
for (int i = 1; i < propertyName.Length; i++)
char character = propertyName[i];