Introduction
This code snippet is Find the second highest value in an array using C#
Code
using System;
using System.Collections;
public class Program
{
public static void Main()
{
int[] array = { 2, 11, 15, 1, 7, 99, 6, 85, 4 };
Array.Sort(array); //sorting array
Array.Reverse(array); // Reverse Sorting array value
Console.WriteLine("Second Highest Value In Array " + array[1]);
foreach (var result in array)
{
Console.Write(result + " "); // Array values
}
}
}OutputSecond Highest Value In Array 85
99 85 15 11 7 6 4 2 1
99 85 15 11 7 6 4 2 1
Demo : https://dotnetfiddle.net/BTsflq
