Tôi có một chuỗi mà tôi đã chuyển đổi thành TextInfo.ToTitleCase và xóa dấu gạch dưới và nối chuỗi lại với nhau. Bây giờ tôi cần thay đổi ký tự đầu tiên và duy nhất trong chuỗi thành chữ thường và vì một lý do nào đó, tôi không thể tìm ra cách thực hiện nó. Xin được cảm ơn trước về sự giúp đỡ.Chuyển đổi chuỗi Để camelCase từ TitleCase C#
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();
}
}
Kết quả: ZebulansNightmare
Kết quả mong muốn: zebulansNightmare
UPDATE:
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();
}
}
Tạo đầu ra mong muốn
Cảm ơn những gì tôi cần. –
Cuộc gọi tốt. Thực hiện các điều chỉnh và cập nhật câu hỏi. –