Q:

Write a C# Sharp program to determine whether the string "birds" is a substring of a familiar

0

Write a C# Sharp program to determine whether the string "birds" is a substring of a familiar. 

Note : Quotation 'two birds with one stone'.

Expected Output :

'birds' is in the string 'Kill two birds with one stone': True                   
'birds begins at character position 10

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
class Example38
{
    public static void Main() 
    {
       string str1 = "Kill two birds with one stone";
       string str2 = "birds";
       bool x = str1.Contains(str2);
       Console.WriteLine("'{0}' is in the string '{1}': {2}",
                          str2, str1, x);
       if (x) {
          int index = str1.IndexOf(str2);
          if (index >= 0)
             Console.WriteLine("'{0} begins at character position {1}",
                               str2, index + 1);
       }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now