c# get first x characters from string code example
Example 1: c# get first 5 characters of string
string result = str.Substring(0,5);
Example 2: how to look for substring in string in c#
String phrase = "this is the ultimate string";
Console.WriteLine(phrase.Contains("this")); //returns True
Console.WriteLine(phrase.Contains("python")); //returns False