How do you make an algorithm that will return the number of elements in an array in C#? -


i have code think going in right direction, need filling in gap. please aware cannot use array.length here , have make algorithm perform same function array.length. here have far:

    public static int size(int[] s, int n)     {         (int = 0; < n; i++)         {             (s[i]          }     } 

this silly assignment c# arrays provide length using array.length property. think should make clear in delivery.

however, stay within rules try this:

int[] array = new int[10]; int count = 0;  // iterate elements in array foreach(int item in array) {     count++; }  // count equal 10 return count; 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -