我有一个字符串,我将其转换为 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();
}
}
产生所需的输出