C#教程
C#控制语句
C#函数
C#数组
C#面向对象
C#命名空间和异常
C#文件IO
C#集合
C#多线程
C#其它

C# String EndsWith()

C# String EndsWith()

C# EndsWith() 方法用于检查指定的字符串是否与该字符串的结尾匹配。如果在此字符串的末尾找到指定的字符串,则返回 true,否则返回 false。

签名

public bool EndsWith(String str)
public bool EndsWith(String, Boolean, CultureInfo)
public bool EndsWith (String, StringComparison)?

参数

str:是一个字符串对象,用于检查指定的字符串是否以它结尾。

返回

返回布尔值,true 或 false。

C# String EndsWith() 方法示例

    using System;  
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
             string s1 = "Hello";  
             string s2 = "llo";
             string s3 = "C#";
             Console.WriteLine(s1.EndsWith(s2));
             Console.WriteLine(s1.EndsWith(s3));
        }  
    }  
输出:
 true
False 
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4