C# Program to Find the Smallest and Largest Elements of an Array Using Predefined Methods

C# Program to Find the Smallest and Largest Elements of an Array Using Predefined Methods Article has many meanings. We are going to know this topic clearly through this article. We hope you like this article.

C# Program to Find the Smallest and Largest Elements of an Array Using Predefined Methods

C# Program to Find the Smallest and Largest Elements of an Array Using Predefined Methods

//C# program to find the smallest and largest 
//elements of an array using predefined methods.

using System;
using System.Linq;

class Sample
{
    static void Main()
    {
        int[] MyArray = { 40,30,20,10,50 };

        int large = MyArray.Max();
        int small = MyArray.Min();

        Console.WriteLine("Largest Element  : " + large);
        Console.WriteLine("Smallest Element : " + small);
    }
}
Largest Element  : 50
Smallest Element : 10
Press any key to continue . . .

Final Words

C# Program to Find the Smallest and Largest Elements of an Array Using Predefined Methods We got to know our topic very clearly. And if you have any doubts about this article you can let us know your doubts via comment.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment