Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Searching a character in a string in C#

You can search a letter in a string by converting the string to character array.

Working example:

If the user wants to search whether the character 'e' is present or not in a string "My name is Forget Code"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace ForgetCode
{
    class Program
    {
       static void Main(string[] args)
        {
            string text = "My name is Forget Code";
            char[] textarray = text.ToCharArray();

            foreach (char c in textarray)
            {
                if (c.Equals('e'))
                {
                    Console.WriteLine("The letter is present");
                    break;
                }

            }
           
        }
    }
}

Output:
The letter is present