Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




Substring() - Method


Substring() Method


The Substring() Method is used to return a new string starting from the start index.


Example :



public class MyApplication
{
    public static void Main(string[] args)
    {
    	string x = "Hello Girl";
    	string y = x.Substring(6);
    	System.Console.WriteLine(y);
    }
}


Output :



  Girl

In the above code, we have declared a String Hello Girl.


string x = "Hello Girl";
C_Sharp


Now, we will extract the substring Girl from the String Hello Girl.


So, we have used the Substring() to extract the substring Girl.


string y = x.Substring(6);
C_Sharp


So, the substring Girl starts from index/position 6.


string y = x.Substring(6);

And we got the output as Girl.

Output :



  Girl