Another extension method… I just ran into the need to humanize some strings into more friendly ones. This can be used to humanize the name of an enumeration. It will turn a “CamelCasedString” into a “Camel Cased String”. public static class StringExtension { /// <summary> /// Humanize a "CamelCasedString" into "Camel Cased String". /// </summary> /// <param name="source"></param> /// <returns></returns> public static string Humanize(this string source ) { StringBuilder sb =new StringBuilder(); char last =char.MinValue; foreach (char cin source ) { if (char.IsLower( last ) ==true &&char.IsUpper( c ) ==true ) { sb.Append(' ' ); } sb.Append( c ); last = c; } return sb.ToString(); } }
Remember Me
dasBlog theme by Mads Kristensen
Concepts LINQ Entity Framework WCF WPF RESTful Web Unit Testing .NET Workflow More >>
Tools Visual Studio Windows IIS Silverlight More >>
Type Screencast Tools Video Newsletter Sample Article Books Magazine How To Demo Course Products More >>