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

String Substring()

BLUF: Mastering String Substring() 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 Substring()

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

The C# SubString function is employed to extract a portion of a String. This portion begins at a designated character index and extends to the conclusion of the string.

Signature

Example

public string Substring(Int32 index)
public string Substring(Int32, Int32)

Parameter

The index parameter is an integer type value that is utilized for passing an index in order to retrieve a substring.

Return

It returns a string.

C# String SubString Method Example

Example

using System; 
    		
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
           string s1 = "Hello C Sharp";
           string s2 = s1.Substring(5);
           Console.WriteLine(s2);
        }  
    }

Output:

Output

C Sharp

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