using System.Text.RegularExpressions;
public static string ToSnakeCase(string str)
return Regex.Replace(str, "[A-Z]", "_$0").ToLower();
public static string ToCamelCase(string str1)
return Regex.Replace(str1, "_[a-z]", delegate (Match m) {
return m.ToString().TrimStart('_').ToUpper();
public static void convert(String s)
char[] ch = s.ToCharArray();
for (int i = 0; i < n; i++)
ch[i + 1] = char.ToUpper(ch[i + 1]);
for (int i = 0; i < n - cnt; i++)
public static void converts(string str)
for (int i = 0; i < n; i++)
public static void Main(string[] args)
Console.WriteLine("Enter the camelcase string");
x: string s = Console.ReadLine();
if (string.IsNullOrEmpty(s))
Console.WriteLine("null values are not to be given");
else if (Regex.IsMatch(s, "[A-Z]"))
Console.WriteLine(ToSnakeCase(s));
Console.WriteLine("invalid string");
Console.WriteLine("Enter the snakecase string");
y: string v = Console.ReadLine();
if (string.IsNullOrEmpty(v))
Console.WriteLine("null values are not to be given");
else if (Regex.IsMatch(v, "_"))
Console.WriteLine(ToCamelCase(v));
Console.WriteLine("invalid string");
Console.WriteLine("enter the string that converts to camelcase");
z: String a = Console.ReadLine();
if (string.IsNullOrEmpty(a))
Console.WriteLine("null values are not to be given");
else if(Regex.IsMatch(a, " "))
Console.WriteLine("invalid");
Console.WriteLine("Enter the string that converts to snakecase");
k: string b = Console.ReadLine();
if (string.IsNullOrEmpty(b))
Console.WriteLine("null values are not accepted");
else if (Regex.IsMatch(b, " "))
Console.WriteLine("invalid string");