From Kurt Schroeder:
namespace Iknowtek.Utils
{
public static class GeneralUtilities
{
/// <summary>
/// will insert a space before each capital letter Kurt Schroeder 20080617
/// Created to deal with enums
/// example: var str = GeneralUtilities.SpacedOutCamelCase( Enum.GetName(typeof(BillingCycle), p.IBillingCycle),1 ));
/// </summary>
/// <param name="str"></param>
/// <param name="idx"></param>
/// <returns></returns>
public static string SpacedOutCamelCase(string str, int idx)
{
if (idx == str.Length)
return str;
if (str[idx].ToString() == str[idx].ToString().ToUpper())
str = str.Substring(0, ++idx - 1) + " " + str.Substring(idx - 1, (str.Length - idx + 1));
str = SpacedOutCamelCase(str, ++idx);
return str;
}
}
}