using System.Linq;
namespace System
{
public static class StringExtensions
{
///
/// Turns a camelCase or PascalCase token into snake_Case.
///
/// The input in camelCase or PascalCase.
///
/// The input converted to snake_Case. It doesn't alter case so you can call either ToUpper or ToLower without
/// any additional penalties.
///
/// Source: https://stackoverflow.com/a/18781533
public static string ToSnakeCase(this string input) =>
string.Concat(input.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString()));
}
}