c.p.
8
Q:

c# substring from index to end

// To get a substring of a string use 'Substring()'
// The first value is the index of where to start and the second
// value is the lenght of the substring.
string str = "Hello World!"
str.Substring(3, 4) // Output: "lo W"
  
// If you only give a starting index, it will go until the end
str.Substring(3) // Output: "lo World!"
14
String phrase = "this is the ultimate string";

Console.WriteLine(phrase.Contains("this")); //returns True
Console.WriteLine(phrase.Contains("python")); //returns False
 
1
//Get a string between a start index and end index    
string str = "How to find a substring in a string";    
int startIndex = 7;    
int endIndex = str.Length - 7;    
string title = str.Substring(startIndex, endIndex);
2
using System; 
class HellWorld { 
  
    // Main Method 
    public static void Main() 
    { 
  
        // define string 
        String str = "Let us code"; 
  
        Console.WriteLine("String    : " + str); 
  
        // retrieve the substring from index 5 
        Console.WriteLine("Sub String1: " + str.Substring(5)); 
  
        // retrieve the substring from index 8 
        Console.WriteLine("Sub String2: " + str.Substring(8)); 
    } 
}
-2

New to Communities?

Join the community