Answers for "camelCase and snakeCase"

C#
0

camelCase and snakeCase

using System.Text.RegularExpressions;

public class Program 
{
    public static string ToSnakeCase(string str) 
    {
		    return Regex.Replace(str, "[A-Z]", "_$0").ToLower();
    }
    public static string ToCamelCase(string str) 
    {
			  return  Regex.Replace(str, "_[a-z]", delegate(Match m) {
				    return m.ToString().TrimStart('_').ToUpper();
			  });
    }
}
Posted by: Guest on July-19-2021

C# Answers by Framework

Browse Popular Code Answers by Language