List VS String()

My friend has asked an interesting question. He asked about what is the different of List and String() [String array].
Um… I cannot see much different, as both of them store a list/array of string.
But actually if I have a choice, I would choose to use List rather than String array.

If we just treat it as general.
List VS Array.
You need to know the size of the array that you are going to create, once the array has been created, you cannot modify the size
of that array again.
If you use Generic List, you will not have that problem. Because it provides you a lot of useful method, E.g. Add, Remove, Insert,
Find, Sort…etc. and the code seems easier to ready as well.

Instead of having to know which slot of the array I need to assign the value to.

You can use the following code to perform Add. In this case you can add as much value as you like by using .Add method

Do you think it does looks better?

Hope you find this useful.
Please correct me if you find my concept is wrong.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.