Use the Substring() method to retrieve substrings : String : String C# Examples


C# Examples » String » String »

 

Use the Substring() method to retrieve substrings









    
using  System;

class  MainClass
{

    public  static  void  Main()
    {
        
        string[]  myStrings  =  {"To",  "be",  "or",  "not",  "to",  "be"};
        string  myString  =  String.Join(".",  myStrings);      
        
        
        string  myString21  =  myString.Substring(3);
        Console.WriteLine("myString.Substring(3)  =  "  +  myString21);
        string  myString22  =  myString.Substring(3,  2);
        Console.WriteLine("myString.Substring(3,  2)  =  "  +  myString22);

    }

}
    
   
  
   



Output

myString.Substring(3) = be.or.not.to.be
myString.Substring(3, 2) = be


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String