Created
April 7, 2014 07:32
-
-
Save machupicchubeta/10016121 to your computer and use it in GitHub Desktop.
convert snake case to camel case in c#
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
"foo_bar".Split(new [] {"_"}, StringSplitOptions.RemoveEmptyEntries).Select(s => char.ToUpperInvariant(s[0]) + s.Substring(1, s.Length - 1)).Aggregate(string.Empty, (s1, s2) => s1 + s2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much for this snippet.
Just one thing:
I have tested your code and it is indeed Pascal Case (which is what I wanted) and not Cammel Case. I just wanted to let you know.
Thanks again.