This article describes the method of C# using List class to implement dynamic variable-length arrays. Share it for your reference. The details are as follows:
Lists in C# can be used as arrays, and there is no need to define the length, it is completely dynamic
class Person { public string Name { get; set; } public string Address { get; set; } } static void Main(string[] args) { List<Person> people = new List<Person>(); (new Person() { Name = "kaka", Address = "22,2nd cross,bangalore" }); //no casting needed Person p = people[0]; }
I hope this article will be helpful to everyone's C# programming.