Best practice when returning an array of values (.NET)

后端 未结 8 761
灰色年华
灰色年华 2021-01-14 14:37

Usually my methods are as the following:

public List Method1(int input)
{
    var output = new List();
    //add some items to output
          


        
8条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 15:15

    It depends on your requirement. All things said and done, iteration through strongly typed arrays is the fastest amongst all collection types. If you do not need to resize/add/search through them, arrays are quite fine.

提交回复
热议问题