How to create an empty list of strings in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        // Create an empty list of strings
        List<string> stringList = new List<string>();

        // Get the size of the list
        int size = stringList.Count;

        // Output the size
        Console.WriteLine("The size of the list is: " + size);
    }
}



/*
run:

The size of the list is: 0

*/

 



answered Jul 22, 2025 by avibootz

Related questions

1 answer 186 views
1 answer 169 views
169 views asked Jan 20, 2017 by avibootz
1 answer 91 views
2 answers 120 views
...