判断string类型的数据末端字符是否为制定字符
string.EndsWith("");
string testA="XiaoMing_Student";
string testB="LiHua_Teacher";
public void Judge()
{
if (testA.EndsWith("_Student"))
{
Debug.Log(testA+"是学生");
}
if (testB.EndsWith("_Teacher"))
{
Debug.Log(testB+"是老师");
}
}
本文介绍了一种在编程中判断字符串类型数据末端字符是否为指定字符的方法,通过使用string.EndsWith()函数,可以轻松实现对字符串如XiaoMing_Student和LiHua_Teacher的判断。
3998

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



