A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# Sharp program to check whether a given substring is present in the given string
Q:

Write a C# Sharp program to check whether a given substring is present in the given string

0

Write a C# Sharp program to check whether a given substring is present in the given string.

Test Data :
Input the string : This is a Test String
Input the substring to search : Test
Expected Output :

The substring exists in the string

All Answers

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

using System;
public class exercise14
{
	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");
	}
}

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