csharp array last element

Code Example - csharp array last element

                
                        int[] array = { 1, 3, 5 };
var lastItem = array[^1]; // 5
                    
                
 

get last element of array csharp

                        
                                string[] str = new string[] {"Java","HTML","jQuery"};
Console.WriteLine("Last element: "+str[str.Length - 1])
                            
                        
 

csharp get last array element

                        
                                string[] items = GetAllItems();
string lastItem = items[items.Length - 1];
int arrayLength = array.Length;