Initialize list with size in c#


public static List<t> listitems = new List<t>(10);

It just creates a list with maximum capacity 10, but the count will be 0 only. It means the list is still empty.

If you want to create a list without any size, you can do it like this,

public static List<t> listitems = new List<t>(10);

No comments:

Post a comment