Ad

Thursday, July 18, 2013

How To Find the Largest Number using Arrays in c#.Net?

Overview:
                In this article i would like to publish an article To Find the Largest Number using Arrays in c#.Net.



Description:
                Array can be defined as a collection of similar dataitems.In C#.Net array act as a ReferenceType.We can access the elements of an array using index values.

Syntax:

                    DataType[] NameOf The Array=new DataType[size];

E.g:
                   int[] a=new int[5];
                                (or)
                   int[] a=new int[]{12,10,1,3,5};
Note:
  1. If we Declare the size of the array it can take exactly that size number of values.
  2. If we are not declare the size of the array then we can accommodate n number of values.
Program:


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace arr
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[] { 1, 55, 2, 65, 33 };
            Console.WriteLine("Minimum Value is:"+a.Min());
            Console.WriteLine("Maximum Value is:" + a.Max());
            Console.WriteLine("Thank You For visiting this Blog");
            Console.ReadLine();
        }
    }
}

  OutPut:

Maximum Value Of Array

 

2 comments:

Unknown said...

bruh, where the code at...this is jus using system

Steven Rugg said...

He's using System.Linq. Min() and Max() are in the Linq namespace.