TextInfo.ToTitleCase に変換し、アンダースコアを削除して文字列を結合した文字列があります。今、文字列の最初と最初の文字だけを小文字に変更する必要がありますが、何らかの理由でそれを達成する方法がわかりません。助けてくれてありがとう。
class Program
{
static void Main(string[] args)
{
string functionName = "zebulans_nightmare";
TextInfo txtInfo = new CultureInfo("en-us", false).TextInfo;
functionName = txtInfo.ToTitleCase(functionName).Replace('_', ' ').Replace(" ", String.Empty);
Console.Out.WriteLine(functionName);
Console.ReadLine();
}
}
結果: ZebulansNightmare
望ましい結果: zebulansNightmare
アップデート:
class Program
{
static void Main(string[] args)
{
string functionName = "zebulans_nightmare";
TextInfo txtInfo = new CultureInfo("en-us", false).TextInfo;
functionName = txtInfo.ToTitleCase(functionName).Replace("_", string.Empty).Replace(" ", string.Empty);
functionName = $"{functionName.First().ToString().ToLowerInvariant()}{functionName.Substring(1)}";
Console.Out.WriteLine(functionName);
Console.ReadLine();
}
}
目的の出力を生成します