在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 // Input strings. 6 const string s1 = "samuel allen"; 7 const string s2 = "dot net perls"; 8 const string s3 = "Uppercase first letters of all words in the string."; 9 10 // Write output strings. 11 Console.WriteLine(TextTools.UpperFirst(s1)); 12 Console.WriteLine(TextTools.UpperFirst(s2)); 13 Console.WriteLine(TextTools.UpperFirst(s3)); 14 Console.ReadKey(); 15 } 16 } 17 18 public static class TextTools 19 { 20 /// <summary> 21 /// Uppercase first letters of all words in the string. 22 /// </summary> 23 public static string UpperFirst(string s) 24 { 25 return Regex.Replace(s, @"\b[a-z]\w+", delegate(Match match) 26 { 27 string v = match.ToString(); 28 return char.ToUpper(v[0]) + v.Substring(1); 29 }); 30 } 31 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论