50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace JD.Kernel.StaticHelpers
|
|
{
|
|
/// <summary>
|
|
/// Helper routines for strings
|
|
/// </summary>
|
|
public static class StringHelper
|
|
{
|
|
#region Whitespace
|
|
|
|
/// <summary>
|
|
/// Splits a camel case expression into sub words.
|
|
/// </summary>
|
|
public static string CamelCaseToSentence(string camelCase)
|
|
{
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
builder.Append(char.ToUpperInvariant(camelCase[0]));
|
|
|
|
foreach (char c in camelCase.Skip(1))
|
|
{
|
|
if (char.IsUpper(c))
|
|
{
|
|
builder.Append(' ');
|
|
}
|
|
|
|
builder.Append(c);
|
|
}
|
|
return builder.ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Characters
|
|
|
|
/// <summary>
|
|
/// Returns true if <paramref name="c"/> is a number.
|
|
/// </summary>
|
|
/// <param name="c"></param>
|
|
/// <returns></returns>
|
|
public static bool IsNumericChar(char c)
|
|
{
|
|
return (c >= '0' && c <= '9');
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|