Advertisement
Guest User

359

a guest
Dec 13th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string s, x, a, b;
  14.             Console.Write("Enter s string: ");
  15.             s = Console.ReadLine();
  16.  
  17.             Console.Write("Enter s string: ");
  18.             x = Console.ReadLine();
  19.  
  20.             Console.Write("Enter a string: ");
  21.             a = Console.ReadLine();
  22.  
  23.             Console.Write("Enter b string: ");
  24.             b = Console.ReadLine();
  25.  
  26.             Console.WriteLine();
  27.  
  28.             Console.WriteLine(chekIfX_ExistInS(s, x, a, b));
  29.         }
  30.  
  31.  
  32.         private static string chekIfX_ExistInS(string str, string searchedStr, string a, string b)
  33.         {
  34.             if (str.Contains(searchedStr) && str.Contains(a) && str.Contains(b))
  35.             {
  36.                 return "Substring \"" + searchedStr + "\" exist in string \"" + str + "\" with start index " +
  37.                     str.IndexOf(searchedStr) + ".";
  38.             }
  39.  
  40.             return "Substring \"" + searchedStr + "\" does not exist in string \"" + str + "\"";
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement