Friday, 1 December 2017

C# Program to Search an Element in an Array


Code:

using System;
using System.IO;
class Program
{
    static void Main()
    {

        string[] array1 = { "cat", "dogs", "donkey", "camel" };
        string v1 = Array.Find(array1,
            element => element.StartsWith("cam", StringComparison.Ordinal));
        string v2 = Array.Find(array1,
            element => element.Length == 3);
        Console.WriteLine("The Elemnt that Starts with 'Cam' is : " +v1);
        Console.WriteLine("3 Letter word in the Array is : " +v2);
        Console.ReadLine();
    }
}


Output:

The Element that Starts With 'Cam' is : Camel
3 Letter Word in the Array is : cat


More C# Programs:

















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...