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# program to check whether a given substring is present in the given string
Q:

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

0

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

All Answers

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

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
public class Stringexercise
{
    public static void Main()
    {
        string str1, str2;
        bool m;
 
        Console.Write("Enter the string : ");
        str1 = Console.ReadLine();
 
        Console.Write("Input the substring to  search : ");
        str2 = Console.ReadLine();
        m = str1.Contains(str2); 
        if (m) // check boolean value is true or false.
            Console.WriteLine("The substring exists in the string.");
        else
            Console.WriteLine("The substring is not exists in the string.");
 
        Console.ReadLine();
    }
}

Result:

Enter the string : techstudy - the complete debugging solution

Input the substring to  search : techstudy

The substring exists in the string.

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now