In most cases for storing data using a generic List<T> over an array is more suitable and lists offers more functionality than an array.

Also you can store different data types in a list in contrast to an array where all data should have the same data type.

If you want replace multi-dimensional arrays you can use List Tuples like

//
var listCountryPopulation = new List<Tuple<int, string, string>>();
listCountryPopulation.Add(new Tuple<int, string, string>(2, "USA", "328 Millionen"));

Below you will see two easy examples to use List Tuples in C# and one practical use of a List Tuple in order to store returned folder and filenames during enumerating a share in an Azure Storage Account.


static void CountryPopulationList()
        {
            var listCountryPopulation = new List<Tuple<int, string, string>>
            {
                Tuple.Create(1, "Germany", "83 Millionen"),
                Tuple.Create(2, "USA", "328 Millinen"),
                Tuple.Create(3, "France", "66 Millionen"),
                Tuple.Create(4, "Spain", "46 Millionen")

            };

            foreach(Tuple<int, string, string> tuple in listCountryPopulation)
            {
                Console.WriteLine(tuple.Item1 + " " + tuple.Item2 + " " + tuple.Item3);
            }

            Console.ReadLine();

        }


If you want to add items to an existing list instance, you have to use the Add method.

For example, if you loop through an object like a share in an Azure Storage Account mentioned above, you create a new List Tuple instance and during enumerating this share you add the returned folder and filenames to this list with the Add method.


static void CountryPopulationList()
        {
            var listCountryPopulation = new List<Tuple<int, string, string>>();

            listCountryPopulation.Add(new Tuple<int, string, string>(1, "Germany", "83 Millionen"));
            listCountryPopulation.Add(new Tuple<int, string, string>(2, "USA", "328 Millionen"));
            listCountryPopulation.Add(new Tuple<int, string, string>(3, "France", "66 Millionen"));
            listCountryPopulation.Add(new Tuple<int, string, string>(4, "Spain", "46 Millionen"));


            foreach (Tuple<int, string, string> tuple in listCountryPopulation)
            {
                Console.WriteLine(tuple.Item1 + " " + tuple.Item2 + " " + tuple.Item3);
            }

            Console.ReadLine();

        }



The following two classes, Program.cs and Azure.cs, uses a List Tuple to get a list of directories and files located in a share on an Azure Storage Account.


Program.cs class
From our C# Console App (.NET Framework), we will reference inside the main method, which is our entry point, the Azure.cs class which contains the code with our list tuple. In this class we call the GetFolders method which will return us the tuple list with the names of the directories and files in our Azure Storage Account.


 class Program
    {
        static void Main(string[] args)
        {

            Azure az = new Azure();
            var folders   = az.GetFolders();

            foreach(Tuple<string, bool> tuple in folders)
            {
                Console.WriteLine("Folder/Filename: " + tuple.Item1 + "  is a directory? " + tuple.Item2);
            }

            Console.ReadLine();
        }
    }



Azure.cs class
Enumerate Azure Storage File Share with C# using a list tuple

Here in line 9 we reference an new list 2-tuple and in line 23 we add the name of the enumerated directory or file to the first tuple and a bool to the second tuple to define if it is a directory or a file.


  public List<Tuple<string,bool>> GetFolders()
        {

            // Azure Storage Account Connection String and share name
            string connectionString = ConfigurationManager.AppSettings.Get("StorageConnectionString");
            string shareName = "braintesting";

            // reference a new list 2-tuple named folders which will include our directories from our share braintesting in our Azure Storage Account
            var folders  = new List<Tuple<string, bool>>();

            // Get a reference from our share 
            ShareClient share = new ShareClient(connectionString, shareName);

            var remaining = new Queue<ShareDirectoryClient>();
            remaining.Enqueue(share.GetRootDirectoryClient());
            while (remaining.Count > 0)
            {
                ShareDirectoryClient dir = remaining.Dequeue();
                foreach (ShareFileItem item in dir.GetFilesAndDirectories())
                {
                    
                    // Add the directory names and filenames to our list 2-tuple
                    folders.Add(new Tuple<string, bool>(item.Name, item.IsDirectory));
 

                    if (item.IsDirectory)
                    {
                        remaining.Enqueue(dir.GetSubdirectoryClient(item.Name));
                    }
                }
            }

            return folders;

        }





Links


How to work with a Tuple in C#
https://www.infoworld.com/article/3095242/how-to-work-with-a-tuple-in-c.html

What’s the difference between Tuple.Create() vs new Tuple?
https://grantwinney.com/tuple-create-vs-new-tuple/

Tuple.Create Method
https://docs.microsoft.com/en-us/dotnet/api/system.tuple.create