Most efficient way to append arrays in C#?

前端 未结 10 2141
挽巷
挽巷 2020-12-02 19:39

I am pulling data out of an old-school ActiveX in the form of arrays of doubles. I don\'t initially know the final number of samples I will actually retrieve.

What i

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 20:23

    I believe if you have 2 arrays of the same type that you want to combine into a third array, there's a very simple way to do that.

    here's the code:

    String[] theHTMLFiles = Directory.GetFiles(basePath, "*.html");
    String[] thexmlFiles = Directory.GetFiles(basePath, "*.xml");
    List finalList = new List(theHTMLFiles.Concat(thexmlFiles));
    String[] finalArray = finalList.ToArray();
    

提交回复
热议问题