String Startswith() - C# Tutorial
C# Course / Strings / String Startswith()

String Startswith()

BLUF: Mastering String Startswith() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: String Startswith()

C# is a powerful, modern language for enterprise solutions. Discover how String Startswith() enhances your development workflow in the guide below.

The C# StartsWith function is utilized to verify if the initial part of the given string object corresponds with the specified string.

Signature

Example

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

Parameter

The str parameter is a string type used to verify the start of a string.

Return

It returns boolean value.

C# String StartsWith Method Example

Example

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);
        }  
    }

Output:

Output

False 
True

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience