c# get array first object code example

Example 1: csharp first element of array

double[] values;
private List<double[]> valueList = new List<double[]>();
void AddNewValues(double d1, double d2, double d3)
{
   values[0] = d1;
   values[1] = d1;
   values[2] = d1;
   valueList.Add(values);
}

void GetAllFirstValues()
{
   var test = valueList.Where(s => s == typeof(double[0]));
}

Example 2: csharp first element of array

using System;

namespace InitArray
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = new int[5];

            array[0] = 1;
            array[1] = 2;
            array[2] = 3;
            array[3] = 4;
            array[4] = 5;
            
            for (int i = 0; i < array.Length; i++) 
            {
                Console.WriteLine(array[i]);
            }  
        }
    }
}