Friends, do you know how to create a .net generic collection in Visual Studio 2019? Today I will explain about Visual Studio How to create a .net generic collection in 2019. If you are interested, come and take a look with the editor. I hope it can help everyone.
Step 1: First we open Visual Studio 2019 (as shown in the picture).
Step 2: Then create a new project (as shown in the picture).
Step 3: Console application>>Next step (as shown in the picture).
Step 4: You can modify the project name, modify the location, and click the "Create" button (as shown in the picture).
Step 5: Create a List generic class collection, where "T" is the type to be used, which can be a simple type, such as string, int, etc.
Code:
//List generic class creates a collection
var intList = new List();
Step 6: Add elements to the collection
Code:
//Add elements
intList.AddRange(new List() { 1, 2, 3,7,8,9 });
Step 7: Loop through to read elements
Code:
//Loop traversal to read elements
Foreach (var item in intList)
{
}
Step 8: Code and output elements
Code:
//Output elements
Console.WriteLine("Read element" + item);
Step 9: Debugging >> Start debugging and run the code (as shown in the picture).
The above is the entire content of how to create a .net generic collection in Visual Studio 2019 brought to you by the editor. I hope it can help you.