Splits string name into a readable string based on camel casing. : String Split « Data Types « C# / C Sharp






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

    
//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
{
    /// <summary>
    /// String helper methods
    /// </summary>
  public static class StringExtensions
  {    /// <summary>
    /// Splits string name into a readable string based on camel casing.
    /// </summary>
    /// <param name="value">The string to split.</param>
    /// <returns>A modified <see cref="string"/> with spaces inserted in front of every, excluding the first, upper-cased character.</returns>
    /// <exception cref="ArgumentNullException"><paramref name="value"/> is a null reference.</exception>
    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();
    }
   }
}

   
    
    
    
  








Related examples in the same category

1.Split with space
2.Split with a list of dividers
3.Split spaces with space
4.Show string in proper case
5.use the Split() method to split strings
6.Splitting StringsSplitting Strings
7.Split and join stringsSplit and join strings
8.Tokenize stringsTokenize strings
9.Char String foreachChar String foreach
10.Split a string delimited by another string and return 2 non-empty elements
11.Split a string delimited by another string and return 2 elements
12.Split the original string at the delimiter and return all non-empty elements
13.Split a string delimited by another string and return all elements
14.Split a string delimited by characters and return all elements
15.Split a string delimited by characters and return 2 non-empty elements
16.Split a string delimited by characters and return 2 elements
17.Split a string delimited by characters and return all non-empty elements
18.Use StringSplitOptions enumeration to include or exclude substrings generated by the Split method.
19.Implements a StringTokenizer class for splitting a string into substrings using a set of delimiters.
20.String Tokenizer
21.Can parse a string representing a string[] into an actual string[].
22.Converts a collection of tags to a single string representation containing the tags separated by a comma
23.Takes in any string and convert it into a Byte array, suitable for e.g. insertion into a REG_BINARY Registry value.
24.Splits the string into lines.
25.Splits the string into words (all white space is removed).
26.Split Quoted String
27.Helper class to split a long word into a single one.
28.Splits the string into an array, using the separator.