Created
September 12, 2013 07:26
-
-
Save Krummelz/6533983 to your computer and use it in GitHub Desktop.
Useful C# Extension Methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// This will return a camel-cased string, so that it reads as a normal string, by adding a space before each capital letter. | |
/// </summary> | |
public static string SpaceOutCamelCasing(this string theWord) | |
{ | |
char[] temp = theWord.ToCharArray(); | |
string Result = ""; | |
foreach (char c in temp) | |
if (c.ToString() == c.ToString().ToUpper()) | |
Result += " " + c; | |
else | |
Result += c; | |
return Result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One liner:
String.Concat(Regex.Split("myCamelCaseString", "(?=[A-Z])").Select(x => x + " "));