Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Array and List - Compatibility in C#

The following code explains the compatibility between Array and List. (Arrays and Generic lists)
For example,
Checking the array.Length and list.Count.

  1. using System;
  2. using System.Text;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6. namespace forgetCode
  7. {
  8. class program
  9. {
  10. public static void Main()
  11. {
  12. int[] array = { 1, 2, 3, 4, 5 };
  13. List<int> list = array.ToList();
  14. Console.WriteLine(array[0] == list[0]);
  15. Console.WriteLine(array.Length == list.Count);
  16. }
  17. }
  18. }


Output:
True
True