Check out example codes for "last elemnet of array in c#". It will help you in understanding the concepts better.
Code Example 1
using System;
public class Demo {
public static void Main() {
string[] str = new string[] {
"Java",
"HTML",
"jQuery",
"JavaScript",
"Bootstrap"
};
Console.WriteLine("Array...");
foreach(string res in str) {
Console.WriteLine(res);
}
Console.WriteLine("Last element: "+str[str.Length - 1]);
}
}
Code Example 2
string[] str = new string[] {"Java","HTML","jQuery"};
Console.WriteLine("Last element: "+str[str.Length - 1])
Code Example 3
using System;
public class Demo {
public static void Main() {
string[] str = new string[] {
"Java",
"HTML",
"jQuery",
"JavaScript",
"Bootstrap"
};
Console.WriteLine("Array...");
foreach(string res in str) {
Console.WriteLine(res);
}
Console.WriteLine("Last element: "+str[str.Length - 1]);
}
}
Code Example 4
Array...
Java
HTML
jQuery
JavaScript
Bootstrap
Last element: Bootstrap
Learn ReactJs, React Native from akashmittal.com