C# program to get the last element from an array

Category > CSHARP || Published on : Monday, November 23, 2020 || Views: 1108 || get the last element from an array in C#


Here Pawan Kumar will explain how to get the last element from an array

using System;

public class Demo {
   public static void Main() {
      string[] Values = new string[] {
         "C",
         "C++",
         "C#",
         "VB.NET",
         "Java"
      };
      Console.WriteLine("Priting complete Array values");
      foreach(string Value in Values) {
         Console.WriteLine(Value);
      }
      Console.WriteLine("Last element: "+Values[Values.Length - 1]);
   }
}