Last active
January 4, 2016 21:19
-
-
Save anakahala/8680515 to your computer and use it in GitHub Desktop.
「property_name」みたいなのを「PropertyName」にする
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> | |
| /// delimiterで区切られた文字をパスカル形式にします | |
| /// </summary> | |
| /// <param name="value">value</param> | |
| /// <param name="delimiter">delimiter</param> | |
| /// <returns>Pascalizeed value</returns> | |
| public static string Pascalize(string value, string delimiter) | |
| { | |
| if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(delimiter)) | |
| { | |
| return string.Empty; | |
| } | |
| StringBuilder sb = new StringBuilder(); | |
| value.Split(char.Parse(delimiter)).Select(v => char.ToUpper(v[0]) + v.Substring(1)) | |
| .ToList().ForEach(v => | |
| { | |
| sb.Append(v); | |
| }); | |
| return sb.ToString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment