Splits string name into a readable string based on camel casing.

image_pdfimage_print

//http://validationframework.codeplex.com/
//License: Microsoft Permissive License (Ms-PL) v1.1

using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;

namespace ValidationFramework.Extensions
{
///

/// String helper methods
///

public static class StringExtensions
{ ///

/// Splits string name into a readable string based on camel casing.
///

/// The string to split. /// A modified with spaces inserted in front of every, excluding the first, upper-cased character.
/// is a null reference.
public static string ToCamelTokenized(this string value)
{

string space = ” “;
if (value.Length ==0)
{
return value;
}
var stringBuilder = new StringBuilder(value.Length);
stringBuilder.Append(value[0]);
for (var index = 1; index < value.Length; index++) { var c = value[index]; if (Char.IsUpper(c)) { stringBuilder.Append(space); } stringBuilder.Append(c); } return stringBuilder.ToString(); } } } [/csharp]

This entry was posted in Data Types. Bookmark the permalink.