programming-examples/c-sharp/Strings/C# Sharp program to check whether a given substring is present in the given string.cs

20 lines
790 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
using System;
public class exercise13
{
public static void Main()
{
string str1,str2;
bool m;
Console.Write("\n\nCheck whether a given substring is present in the given strig :\n");
Console.Write("-------------------------------------------------------------------\n");
Console.Write("Input the string : ");
str1 = Console.ReadLine();
Console.Write("Input the substring to search : ");
str2 = Console.ReadLine();
m=str1.Contains(str2); // boolean value tapped hare
if (m) // check boolean value is true or false.
Console.Write("The substring exists in the string.\n\n");
else
Console.Write("The substring is not exists in the string. \n\n");
}
}