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

C# String StartsWith()

C# String StartsWith()

C#StartsWith() 方法用于检查此字符串实例的开头是否与指定字符串匹配。

签名

public bool StartsWith(String str)
public bool StartsWith(String, Boolean, CultureInfo) 
public bool StartsWith(String, StringComparison)

参数

str: 是字符串类型参数,用于检查字符串的开头。

返回

返回布尔值。

C# String StartsWith() 方法示例

    using System; 
    		
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
           string s1 = "Hello C Sharp";
           bool b1 = s1.StartsWith("h");
           bool b2 = s1.StartsWith("H");
           Console.WriteLine(b1);
           Console.WriteLine(b2);
        }  
    }  
输出:
 false 
True 
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4