要判断 C# 中的字符串是否以逗号结尾,有几种方法可以实现:
方法1:使用 Substring 和 EndsWith 方法
string str = "Hello, World,";
bool endsWithComma = str.EndsWith(","); // 判断字符串是否以逗号结尾
Console.WriteLine(endsWithComma)
本文介绍了在C#中使用Substring和EndsWith方法,以及TrimEnd和[]访问器判断字符串是否以逗号结尾的两种实用技巧。
要判断 C# 中的字符串是否以逗号结尾,有几种方法可以实现:
方法1:使用 Substring 和 EndsWith 方法
string str = "Hello, World,";
bool endsWithComma = str.EndsWith(","); // 判断字符串是否以逗号结尾
Console.WriteLine(endsWithComma)
5631
1422

被折叠的 条评论
为什么被折叠?