String start with

In this chapter you will learn:

  1. How to check if a string starts with another string

Start with another string

In the same way we can use StartWith, EndWith methods.

using System;//from j  a  v a  2 s . com

class Sample
{
    public static void Main()
    {
        string s = "java2s.com";

        Console.WriteLine(s.StartsWith("java"));
        Console.WriteLine(s.EndsWith("java"));
    }
}

The output:

Next chapter...

What you will learn in the next chapter:

  1. Insert String in the middle
Home » C# Tutorial » String
string
String creation
Char in string
Compare strings
String equality
String concatanation
String copy
String Join
String split
String Search for Index
String contains
String start with
String insert
String case
Replacing substring
Remove from a string
Substring
Escape Characters
String verbatim
String padding
Switch on String
String trim
String intern
String normalization
Empty String